|
-
Mar 15th, 2008, 04:53 PM
#1
Thread Starter
PowerPoster
Form submit question
I've got a simple form on my page (name, email and how you found me) which works fine and writes the details to a txt file once the form has been submitted. However, I seem to be getting people you submit the form and then refresh the page (for whatever reason) and their details get added again to the txt file.
My question is: Is there a way to check if a person refreshes the screen and if they have bypass the writing to the txt file routine?
-
Mar 15th, 2008, 05:05 PM
#2
Re: Form submit question
There is a way to prevent it from happening in the first place. Have the form submit to a processing page an send a redirect header after processing.
As for checking you could open the text file and look for the the appropriate name / email combination but that would be an intensive process.
-
Mar 16th, 2008, 06:21 PM
#3
Re: Form submit question
Using a database is out of the question?
-
Mar 16th, 2008, 07:03 PM
#4
Re: Form submit question
Whether you use a database or not you will still have the problem of lingering POST data unless you use a 303 redirect from your POST handler page.
PHP Code:
header('HTTP/1.1 303 See Other'); header("Location: http://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}");
303 responses are not cacheable, so navigating backwards from the redirected response will function as expected.
Last edited by penagate; Mar 16th, 2008 at 07:07 PM.
-
Mar 16th, 2008, 07:50 PM
#5
Re: Form submit question
I never thought of using the redirect before. I've been using a SELECT query to see if the same "post" was saved by the same user/ip/email/message/etc.
-
Mar 16th, 2008, 07:52 PM
#6
Re: Form submit question
You should use a composite primary key for that. That will save you one query per post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|