Haven't been on in a while cause I got discouraged by this problem I am having. It is probably stupid and I am probably missing something, but what I am trying to do is a user will enter a number. Depending on what that number is ($numbers), the loop will loop that many times to create that many text boxes.
I am submitting this form back to the php page via php_self. Since I don't know what number is going to be entered by the user, I put the value entered into each textbox into an array title[]. My page requires that all text boxes be filled in, so if the user enters 12 for their number, they have to fill in all 12 textboxes. When the user submits the page, when its reloaded, the page checks to see if there is an empty field, if so it produces and error message and reloads the form. My problem is when reloading a page that has an error, I can't each textboxes entered value to display in the box. This is neccessary since the user would have to reenter every field even if just one is blank. And since I don't know what number is origianlly entered, I can't put $titles[0] so on as the value. When I try to put $titles[] in as the value php comes up with an error message. I want to know can I make a foreach or while statement that will redisplay entered values in their textboxes without knowing the amount in the array. Here is the code I have so far.
Here for testing purposes I define $numbers, normally it is a user defined number
$numbers = 12;
echo"<body bgcolor=\"#888888\">
<center><font size=\"2\" face=\"verdana\">ENTER YOUR NAMES</font><br><br><font size=\"1\" face=\"verdana\"><br>STEP 2 OF 4<br><br><br>
Please fill in each box below with the corresponding names. Make sure all entries are complete before clicking the submit button. If you wish to enter in another number or change other info, click <a href=\"member.php\">HERE</a> to go back to your member page and restart the upload process. <br><br><br>";
if ($error == true){
echo"<center><span style=\"color:red\"><font size=\"2\" face=\"verdana\">All entries must be complete. Please Try Again.</font></span></center><br>";
}
echo"<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
<table width=\"400\" bgcolor=\"#EEEEEE\">
";
$i = 1;
while ($i <= $numbers){
echo"<tr><td align=\"left\" valign=\"top\">".$i."</td><td align=\"center\"><input type=\"text\" size=\"40\" value=\"".$_POST['name']."\" name=\"name[]\"><br><br></td></tr>";
$i++;
}
echo"<tr><td></td><td align=\"center\"><input type=\"image\" src=\"images/submitbutton.jpg\" name=\"enternames\"></td></tr></table></form><br><br>
In the above example the value "ARRAY" is displayed which I realize means that a specific value is not being pointed to, so how can I put each value in its correct text box? Thanks