Jump to content

Help! Multiple pages passing variables, stuck on the last one...


morocco-iceberg

Recommended Posts

I'm supposed to use a do while loop to list the names of the children... and everything I've attempted just won't work. There are three pages:

 

Page One asks how many children the person has...

<form action="kids.php" method="post">
How many children do you have? <input type="text" name="number" value="" />
<input type="submit" name="one" value="Next" />

 

Page Two then asks for the childrens names and genereates an input box per child...

       <?php
	$number=$_POST['number'];

	echo "You have $number children.<br /><form action=\"kidsResults.php\" method=\"post\"><input type=\"hidden\" name=\"number\" value=\"$number\" />";
	for($counter=1;$counter<=$number;$counter+=1){
		echo "Name of child $counter <input type=\"text\" name=\"$counter\" value=\"\" />";
	}
	echo "<input type=\"submit\" name=\"two\" value=\"Next\" /></form>"
   ?>

 

But I can't seem to get my head around Page Three, which is supposed to list the children's names...

       <?php
	$number=$_POST['number'];
	$counter=0;
	while($counter<=$number){
	$counter=$counter+1;
	$counter=$_POST['$counter'];
	echo $counter;
	}
	?>

 

Help! :confused:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.