Page 1 of 1

PHP Forms

Posted: Mon Jul 04, 2005 2:46 am
by vivekjain
Hi,
I am developing an application in PHP. I have a HTML form and on submitting it takes me to a PHP page. Now if I press the back button, the form values disappear. Is there anyway that I could have the form values on pressing the back button of the browser? thanks

Posted: Mon Jul 04, 2005 4:31 am
by icarpenter
You could write the value into a session variable in the recieving page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..ble. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty.. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..e'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION&#1111ng page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..e value into a session variable in the recieving page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..ge. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['va variable in the recieving page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..e value into a session variable in the recieving page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable bein1;'value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..riable in the recieving page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..a9a]$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page ]
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..e value into a session variable in the recieving page. ie:-

Code: Select all

$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to sup$_SESSION['value']=$_POST['value'];
And in your first page echo the session variable. ie

Code: Select all

echo @$_SESSION['value'];
Using the @ to suppress the errors you will recieve when the page is loaded the first time due to the session variable being empty..

Posted: Mon Jul 04, 2005 4:32 am
by Chris Corbyn
The back button behaves a bit awkwardly when trying to do someting like this. More often than not it does NOT load the page again so session variables may not be of any use here.

The best thing to use with the back button is a bit of JavaScript in a hidden IFRAME. You store JavaScript variables in the IFRAME and then pop them back into the form fields onLoad.

Posted: Tue Jul 05, 2005 10:21 am
by andylyon87
Why dont you have the form on the same page as the analysis of the form and just use hidden fields. This way you can set the value of the boxes and if one is empty that shouldnt be then the rest will be as they were.

e.g.

Code: Select all

<?
print("<input type=text name=test value=$test size=20>");
?>