Page 1 of 1

Forms

Posted: Mon Apr 12, 2004 7:39 pm
by tim
Is there any code I can enter that will save the data in the input fields?

I have a <form action=verify.php etc etc

and on verify.php I have a ton of validation terms, with a
click <a href='javascript:history.go(-1)'>here</a> to go back

and when it does, the fields are blank, how do i get it to save the data?

cheers

Posted: Mon Apr 12, 2004 8:09 pm
by ol4pr0
I am not sure.. but i think you are asking the impossible here.

Atleast as long as you calling ti with the java............................go(-1)

Posted: Mon Apr 12, 2004 8:16 pm
by tim
well JS or not, is there a way?

a header(cache?????

I googled but came up with empty hands. even if I use a:
<a href=page.php>Click here to go back and fill in the requierd fields</a> deal it does not save the data

Posted: Mon Apr 12, 2004 8:22 pm
by markl999
Try header("Cache-control: private");

Posted: Tue Apr 13, 2004 7:56 am
by magicrobotmonkey
If you're using sessions, its cake!

Code: Select all

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

Posted: Tue Apr 13, 2004 4:09 pm
by tim
markl999 wrote:Try header("Cache-control: private");
Sorry mark, that dont work either (as I was fiddling with header information)

malcomb - I didnt really want to assign each input field a session variable JUST to get this effect. I was hoping there would be an alternate way

anymore ideas?

Posted: Tue Apr 13, 2004 4:14 pm
by MarK (CZ)
Well, when you submit a form, you push a lot of data with it, right? So, just make a link backwards but with all the data (e.g. whole $_GET array) attached to it as part of URL.

Then in the form will just be:

Code: Select all

<INPUT TYPE="text" NAME="textField1" VALUE="<?= textField1 ?>">

Posted: Tue Apr 13, 2004 4:16 pm
by tim
Update - the top of my page has the following code

Code: Select all

<?
header("Cache-control: private");
session_start();
?>
This gave no errors - I changed the order knowing the session_start should be first.

it works, BUT if I use the <a href=page.php>click me to go back</a> the information is lost. However, the back button as well as the JS (see oldpr0, you was wrong :wink:) works liek a charm

excellent, thanks mark (shooter) & everyone!!!!!!