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:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.