How to restore form data?
Posted: Tue Oct 26, 2010 4:56 pm
Using a simple form in a file called test.php, the user enters:
name
address
city
state
country
in the appropriate textboxes and hits the SUBMIT button.
This opens a new php script called addr_info.php shown below:
----------------------------
------------------------------------
The session variables are displayed and this now works fine (thanks to Greg in another thread).
Now, suppose that the user realizes that he entered one or more values incorrectly. I provided a LINK that the user can click on to return to the form, but the textboxes are all clear.
So I tried some things I found on the net, like:
But this did not work. I also tried:
But this did not work either.
I sure could use some advice on how to return to the form in order to make changes without having to type everything over again.
Thanks.
name
address
city
state
country
in the appropriate textboxes and hits the SUBMIT button.
This opens a new php script called addr_info.php shown below:
----------------------------
Code: Select all
<?php
session_start();
$name = $_POST['name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$postalcode = $_POST['postalcode'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$country = $_POST['country'];
echo "<hr />";
echo "CUSTOMER INFORMATION PROVIDED<br /><br />";
echo "<strong>$name</strong> <br />";
echo "<strong>$address1</strong> <br />";
if (empty($address2) == FALSE)
echo "<strong>$address2</strong> <br />";
echo "<strong>$city, $state</strong> <br />";
echo "<strong>$country</strong><br />";
echo "<strong>$postalcode</strong> <br /><br />";
echo "<strong>$phone</strong> <br />";
echo "<strong>$email</strong> <br />";
echo '<br /><a href="orderform_shipping.php">EDIT</a>';
echo "<hr />";
?>The session variables are displayed and this now works fine (thanks to Greg in another thread).
Now, suppose that the user realizes that he entered one or more values incorrectly. I provided a LINK that the user can click on to return to the form, but the textboxes are all clear.
So I tried some things I found on the net, like:
Code: Select all
<input name="name" type="text" id="name" value="<?=$_REQUEST['name']?>"/>Code: Select all
<input name="name" type="text" id="name" value="<?php echo $name; ?>"/>I sure could use some advice on how to return to the form in order to make changes without having to type everything over again.
Thanks.