I am trying to send data from multiple checkboxes (id[]) and create an array "info" in php to allow me to run a script for each value (however the quantity of values may change each time) however first I am trying to display the content of each array value. I am not quite sure how to put my array populating line to save all the content to the array.
HTML
echo("<input name='id[]' type='checkbox' value='".$shopnumb."'>");
my hopeful processing code currently is -
$info=$_POST['id[]']; Echo(array_values($info));
what do I need to do to make the content sent by post from the form checkboxes populate the array info
any help is greatly appreciated
edited for clarification.
You can create arrays in form fields using square brackets. That means you can name fields like account[first_name] and account[last_name] and in most server-side languages, you will end up with an 'account' array.
The PHP built-in variable $_POST is also an array and it holds the data that we provide along with the post method.
Use the POST Method to Send an Array From a Form in PHP. We use the POST method to send data from a form in PHP. The POST method is an HTTP request method that creates or adds resources to the server. We use it when we have to send sensitive information like passwords.
Change
$info=$_POST['id[]'];
to
$info=$_POST['id'];
by adding []
to the end of your form field names, PHP will automatically convert these variables into arrays.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With