Ensuring that Form is only submitted once (session vars?)

From: Date: Sat, 22 Dec 2001 06:09:30 +0000
Subject: Ensuring that Form is only submitted once (session vars?)
Groups: php.general 
Request: Send a blank email to php-general+get-78542@lists.php.net to get a copy of this message
I was wondering if there is a way to ensure that a form is only submitted once. I have a script that saves a lot of information to the disk and if the user uses the back button and then resubmits the form, it will cause major problems. I jave looked into using javascript to fix this, but it doesn't seem like there is an easy way using javascript. In the process of looking into this, someone recommended using a session variable. I have never used sesion variables, but tried a sample code in the documentation: <?php session_register ("count"); $count++; ?> Hello visitor, you have seen this page <?php echo $count; ?> times.<p> <php? # the <?=SID?> is necessary to preserve the session id # in the case that the user has disabled cookies ?> To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> but I get an error saying "Warning: Cannot send session cookie - headers already sent by (output started at c:\server\apache\htdocs\session.phtml:5)" and "Warning: Cannot send session cache limiter - headers already sent (output started at c:\server\apache\htdocs\session.phtml:5) in c:\server\apache\htdocs\session.phtml". So two questions, first is a sesssion variable the way to go in ensuring that the user doesn't use the back button to resubmit a form, and secondly why am I getting this errors when I just cut and paste the example code into a sample page? Thanks for any direction and help, Andrew V. Romero

« previous php.general (#78542) next »