I am trying to get information from an html form and pass it to my php file as an array
here is a snippet of the code for my html form:
<form action ="upload.php" method="post">
Name<input id= "n" type="text" name="info[name]" /><br />
Address: <input id="a" type = "text" name="info[address]" /><br />
City: <input id="c" type = "text" name="info[city]" /><br />
</form>
then in my php file I tried to print the content:
$information = $_POST['info'];
echo $information['name'];
but nothing gets printed to the page
I don’t think you can do that (shove it all into a separate array (apart from
$_POST)) directly with your HTML. You’ll have to do some extra PHP work at the beginning.Firstly, for the love of all that is holy, make your HTML input names cleaner:
And now, for the PHP:
Happy coding!