Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Quote:
Originally Posted by nasaboy007
one thing you could do is input an ID number urself as a primary key rather than letting mysql generate it incrementing-ly. when you make the form where the user adds the info, you could find the highest number ID, add one to it, and put it as a hidden field. once they hit submit, all the info will be added plus that ID number. however, since it already had retrieved the highest id number when the form was generated, hitting refresh would send the same id number and you coul djust do a check to see if that id number already exists.
at least, i think that would work... give it a try.
|
Excellent answer, but I cannot give you tp anymore. I have to spread some more before ;-)
Just one remark: don't use this key as a field in db.
Check the form hidden field against a session saved value.
like this:
1) user Tom access a page with a form. The PHP script add tho the form an hidden field which contains a random hashed value ( look at http://www.php.net/manual/en/function.uniqid.php ).
At the same time, save that hashed value into the session, like $_SESSION['formHash']
2) On the form processing, start by checking that there is an hidden hash value, and compare it to the session one.
If the values are identical, process the form. If not, redirect the user to an message page, telling him what happened.
One work less solution would be to integrate the generation/session saving of the hash value in a prepended php page. That way, another value would be generated on each page without you to have to think about it.
Just one warning: if you have ajax calls, this will modify the session hash behind the curtain, thus invalidating your currently displayed form.
Think to filter those ajax requests out.
__________________
Only a biker knows why a dog sticks his head out the window.
|