Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Prevent Resubmit of Form - avoid duplicate entry
Old 04-25-2005, 01:46 PM Prevent Resubmit of Form - avoid duplicate entry
Junior Talker

Posts: 2
Trades: 0
Hi,
I have a form which get post on same page. but the problem is that if someone clicks the refresh button the form gets submitted again and i get duplicate entry in DB, how should i prevent it?

Thanx in advance
Anand
anand_paranjape is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-26-2005, 07:35 AM
Gary_Pinkett's Avatar
Junior Talker

Posts: 4
Trades: 0
There are a few ways you could do this

1) The most obvious, redirect to another page which doesn't have the code on it

2) Store a session after the script does its business.

PHP Code:
if( $_SESSION['jobDone'] != true ) {
// your database code
$_SESSION['jobDone'] = true;

Needs cookie support on the user's side, unless you fancy passing around the session id.

3) Check the referring page, although - troublesome as some people like to mess with that header (including myself)


Its probably best to redirect to a different page, although - the user can of course hit back which depending on a few factors could indeed set the script going again (in the worst case scenerio). A combination of a different page and sessions can be an effective solution.

Theres a couple of other ways to combat this, but for ease and simplicity I think what I've mentioned are commonly used.
__________________
Classic Gaming for the Next Generation,
Please login or register to view this content. Registration is FREE
Gary_Pinkett is offline
Reply With Quote
View Public Profile Visit Gary_Pinkett's homepage!
 
Reply     « Reply to Prevent Resubmit of Form - avoid duplicate entry
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14704 seconds with 12 queries