Page 1 of 1

Keeping entered details when pressing BACK button

Posted: Mon Jul 25, 2005 3:59 am
by nutkenz
When people registrate and get an error, they have to re-enter all information when they go back.

See http://ac-auction.com/register.php if you don't know what I'm talking about.

How can I make it so that all the info doesn't dissapear?

Posted: Mon Jul 25, 2005 5:23 am
by wwwapu
One way of doing it is by session

Code: Select all

<?php
session_start()

if(isset($_SESSION['form_field'])
	$form_field=$_SESSION['form_field'];
}else $form_sield='';
?>

<form ...>
<input type="text" name="form_field" value="<?php print $form_field ?>">
...
Set all fields to something and then store them into session and read from it.

Posted: Mon Jul 25, 2005 5:37 am
by mickd
i think it depends on what vesion of IE and what IE you use that keeps the info when you press back.

i believe (not tested) is that you can use header() command to go back to the login page with the entered info in the url and using $_GET to display the info back in the form like

HANDLEREGISTER.PHP
(if headers were sent already for some reason you could use ob_Start
http://php.planetmirror.com/manual/en/f ... -start.php)

Code: Select all

$oldvalue = $_POST['oldvalue'];
$value = "value=" . $oldvalue . "";
header("location:register.php?$value");

REGISTER.PHP:

Code: Select all

<?php
$value = $_GET['value'];
echo '<input type="text" name="test" size="25" value="$value>"';
?>
like i said i got no idea if this works cos im pritty new to this stuff and its only a theory.


EDIT: or do what he said above ;) wow took me so long to post this lol.

Posted: Mon Jul 25, 2005 8:03 am
by dyonak
Add the following line of code to your page(s), this assumes you already have a session_start(); call and should be added directly after it.

Code: Select all

header("Cache-control: private");
Some good information on sessions - http://www.phpfreaks.com/tutorials/41/0.php.

Posted: Mon Jul 25, 2005 9:19 am
by nutkenz
dyonak wrote:Add the following line of code to your page(s), this assumes you already have a session_start(); call and should be added directly after it.

Code: Select all

header("Cache-control: private");
Some good information on sessions - http://www.phpfreaks.com/tutorials/41/0.php.
Thx, simple solutions r always best :)