Log in

View Full Version : PHP remember (?)



jamiller
02-11-2008, 03:59 PM
So I'm building a 3 part (3 different pages) form. The first page is the actual filling out of the form. The 2nd page is there to allow the user to review the form and the 3rd page is the actual sending of the form.

On the second page I have a "back" button in case the user needs to change something before sending. However, when the user clicks the back button (I'm currently using javascript:history.go(-1) ) all the fields are empty and they ideally should have the input the user just entered. So they should be "remembered."

Does anyone know how to accomplish this? Every comment and help with this is greatly appreciated!

Cheers,

Jeff

Master_script_maker
02-11-2008, 08:35 PM
set a cookie on the second page and retrieve on the first:

<?php
$_COOKIE['something']=$_REQUEST['something'];
?>

<input type="text" name="something" value="<?php if(isset($_COOKIE['something'])) echo $_COOKIE['something']; ?>

jamiller
02-11-2008, 09:16 PM
Hmm, not working but may have something to do with using $_SESSION. I did notice that when I started using this that it no longer remembered the entries automatically.

jamiller
02-11-2008, 09:52 PM
Oops! Newb mistake, I got it working now.

Thanks!!

tech_support
02-12-2008, 05:29 AM
It's

setcookie('something',$_POST['something']); //or $_GET
Don't use $_REQUEST, it's a security risk.