Repost - Form/Session Problem with sample code = Probably easy question - Thanks for any help!

From: Date: Sun, 25 Jan 2004 21:11:18 +0000
Subject: Repost - Form/Session Problem with sample code = Probably easy question - Thanks for any help!
Groups: php.general 
Request: Send a blank email to php-general+get-175693@lists.php.net to get a copy of this message
I am trying to use a back button to allow a user to change submitted form values. The problem I am having is that when they submit the form a second time, regardless of what is entered, the variable $test does not change and keeps only the first value assigned to it! I am able to solve this by using session_unset($test); but I don't understand what is happening/why I should need to do this. Any help appreciated, here is some sample code to illustrate. Running this, only what is typed in first for $test is kept after that it will not take on new values! 1.php ------- <?php session_register("test");?> <a href="2.php">NEXT</a> 2.php ------- <?php session_start();?> <form name="form1" id="form1" method="post" action="3.php"> <input type="text" name="test" id="test" value="<?php echo $test;?>"/> <input type="submit" name="Submit" value="Submit" /> </form> 3.php ------- <?php session_start(); echo "You entered: ".$test; ?> <a href="2.php">START OVER</a>

« previous php.general (#175693) next »