Welcome to W3Courses

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++;
}

?>
 

Average: 1 (1 vote)