Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001122

[PHP] Ensuring that Form is only submitted once (session vars?) From: Andrew V. Romero (avr <email protected>)
Date: 12/22/01

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>