Thanks!!!
catching refreash
Moderator: General Moderators
-
mike123456789
- Forum Newbie
- Posts: 2
- Joined: Thu Jan 15, 2004 1:41 am
catching refreash
Hi, i'm fairly new to php and having a problem when the refresh button is clicked. I have a form that calls itself when the submit button is hit. It insterts fine however when i click refresh, the insert command is called again resulting in a duplicate key errror. Is there any php commands that will catch the refresh button to stop the instert query from begin exec again?
Thanks!!!
Thanks!!!
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
-
timhortons
- Forum Commoner
- Posts: 29
- Joined: Thu Jan 15, 2004 11:48 am
- Location: Calgary, AB, Canada
Thats what I'd suggest.McGruff wrote:If your db structure already prevents a duplicate row you're halfway there.
Before carrying out the INSERT, check for an existing row with the same value in the unique col as the one you are about to try to insert.
As well, I'm not sure how well this works, or if it does, I tried once but I cant remember what happened, but at the bottom of all my form processing, I manually set the POST field to null, or ''... like
$_POST = null;
[edit] Opps, yeah, the null thing wont work, hehe, it just occured to me that when you refresh, you re send the data... it over rides setting it to null... but, yeah, you can prevent multiple inserts by making sure the stuff your inserting doesnt have the same key as something already in the table [/edit]
-
mike123456789
- Forum Newbie
- Posts: 2
- Joined: Thu Jan 15, 2004 1:41 am