Pass Array from Multipart/Form-data Post Method or Query String with Foreach Function in PHP
You can have your form build an array of mutiple text box values and then pass it. The problem is that is global variables are on, it will work but if global variables are off you will have to retrieve each element like the following. If you are using the query string, replace $_Post with $_Get
<?php
echo("<form name='multiupload' enctype='multipart/form-data' method='post' action='{$_SERVER['PHP_SELF']}'>");
for($num=1;$num<=3;$num++)
{
echo("Title: <input type='text' size='20' name='title[]' /><br>");
}
echo("<input type='submit' name='Submit' value='Process' />");
echo("</form>");
$title = $_POST['title'];
$i=0;
while($title[$i]==true)
{
echo("Title: $title[$i]<br>");
$i++;
}
?>
Related Articles
- Add an Automatic / Dynamic Copyrighted Year Message in PHP
- Php Mail Function with Html Header
- How to check if an email address exists without sending an email?
- Use in_array function to check if a value exists in an array using PHP
- Loop through an Array using Foreach Function in PHP
- Delete File or an Image from the Server using PHP
- Encrypt Decrypt using the Rijndael 256 Mcrypt Function in PHP
- Encrypt Decrypt using the Rijndael 256 Mcrypt Class in PHP
