RE: [PHP] Prevent storing data when reload

2002-12-03 Thread Peter Houchin
yep have the submit got to another page and then have a header location in
there to go back to the original page  that the form is on

 -Original Message-
 From: Lars Espelid [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, 4 December 2002 10:17 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Prevent storing data when reload


 Hello,

 I have a php-page whith a form-schema which stores data to a
 mysql-database
 on submit. (The schema posts data to the same page (php-self).)

 When I reload the page the data gets stored once more. I'm sure this is a
 well known problem. Are there any smart tricks to prevent this from
 happening?

 Thanks!

 Lars



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Prevent storing data when reload

2002-12-03 Thread Justin French
 When I reload the page the data gets stored once more. I'm sure this is a
 well known problem. Are there any smart tricks to prevent this from
 happening?

Yes, and they get discussed on this list almost daily... a quick search
would have helped.

1. the script that does all the validating and inserting SHOULD NOT send
any output to the browser... after insert, put in a header(Location:
script.php?action=thanks) style redirect.

This means that if the user hits refresh, they will only be refreshing the
thanks page, NOT the insert page, because it never gets to the browser.

Yes, this can all be done in one script, it may need some re-organisation
though.

2. when generating the HTML form, include a hidden field with a unique
string in it.  Insert this string with the rest of the form data, and make
sure that this string is only inserted once... so, if they hit refresh,
you'll know that the form has already been submitted, and the data already
inserted, so don't insert it again :)

Cheers


Justin French

http://Indent.com.au
Web Development  
Graphic Design



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Prevent storing data when reload

2002-12-03 Thread Hugh Danaher
put
if (!isset($blocker))
{
your form goes here
within your form add
print input type=hidden name=blocker value=1
end your form
}

With this, your input form is on the page when the page first loads (and
$blocker is not set), but disapears when the data is submitted and the page
reloads.  Even if the user hits the refresh button on the browser, the
$blocker variable is still set and the form doesn't reapear.
You can chain up a bunch of these and accomplish with one page what would
have taken several.
Hope this helps,
Hugh

- Original Message -
From: Lars Espelid [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, December 03, 2002 3:17 PM
Subject: [PHP] Prevent storing data when reload


 Hello,

 I have a php-page whith a form-schema which stores data to a
mysql-database
 on submit. (The schema posts data to the same page (php-self).)

 When I reload the page the data gets stored once more. I'm sure this is a
 well known problem. Are there any smart tricks to prevent this from
 happening?

 Thanks!

 Lars



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Prevent storing data when reload

2002-12-03 Thread Jason Wong
On Wednesday 04 December 2002 07:39, Justin French wrote:
  When I reload the page the data gets stored once more. I'm sure this is a
  well known problem. Are there any smart tricks to prevent this from
  happening?

 Yes, and they get discussed on this list almost daily... a quick search
 would have helped.

If only browser makers made their browsers behaved properly according to 
specs. Most of these page refreshing problems occur when people use the 
BACK button after they filled in a form (probably to see what they filled 
in). In stupid browsers like IE and Mozilla it _forces_ you to repost the 
data. IOW the back button doesn't really go back, to the previous state, like 
what the specs say it should do.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Above all else -- sky.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php