VERY IMPORTANT: Sessions in Pages with a Form !

From: Date: Wed, 27 Sep 2000 05:58:54 +0000
Subject: VERY IMPORTANT: Sessions in Pages with a Form !
Groups: php.general 
Request: Send a blank email to php-general+get-17720@lists.php.net to get a copy of this message
Hello list, I have a big trouble: When I use sessions on a page that also has a form in it the back button doesn't work. Like when a subscriber gets an error from my script saying that he didn't fill the form out completely and he tries to hit back button of his browser the whole form disappears. Every single field becomes empty. I know for sure that it is something that has to do with sessions, since commenting them, back button will show you "your" form and not an empty one. here's a piece of code I combined to explain you what I meant: <? session_start(); session_register("location"); if($Submit) { echo 'Submitted Staff:<P>'; echo $text.'<BR>'; echo $textarea.'<BR>'; echo $location.'<P>'; echo 'Now, check this out: click <A HREF="javascript:history.back()">back button</A> and see if the text you were typing is still there...'; } else { ?> <FORM METHOD="POST" ACTION="<?=$PHP_SELF?>"> <BR>Text: <INPUT TYPE="text" NAME="test"> <BR>Text Area: <TEXTAREA NAME="textarea" ROWS="2" COLS="20"></TEXTAREA> <BR><INPUT TYPE="submit" NAME="Submit" VALUE="Submit This Form"> </FORM> <? $location = $SCRIPT_NAME; } ?> If you try it you should then see that on back button what you just filled in the form will be gone. Comment the session start/register and it will work. It is very important for me to resolve this problem, since we saw a BIG drop in subscriptions since I started using sessions in the pages using forms. I know few ways to fix it, like: registering the sessions with the field values, outputting the data again when there's an error, recording the data submitted and prompting only for the missing one.. but, it's hard to explain why, I REALLY NEED the back button to work with sessions just like it would be without them, Please Help. Thank you, Guys. Maxim Maletsky - maxim@j-door.com <mailto:maxim@j-door.com> Webmaster, J-Door.com / J@pan Inc. LINC Media, Inc. TEL: 03-3499-2175 x 1271 FAX: 03-3499-3109 http://www.j-door.com <http://www.j-door.com/> http://www.japaninc.net <http://www.japaninc.net/> http://www.lincmedia.co.jp <http://www.lincmedia.co.jp/>

« previous php.general (#17720) next »