+ 1

How to prevent form resubmission on page reload without the use of $_SESSION?

I'm making a self-referencing sticky form. I need this type in order to display error and not to lose already input data of the user. The form works fine, give proper error and others except when the successful form page is reloaded the data got duplicated in my database. I have look up in Google for an answer but most of the answer use _$SESSION. So I don't even bother to read it. Mine is made following the tutorial of "head first PHP and MySQL" book. So if anyone have solved such a problem please teach me

16th Jan 2017, 8:30 PM
RanjOyHunTer
RanjOyHunTer - avatar
6 Answers
+ 2
I see, then use unset($_POST['btnsbmt']) when mysql finished, so if you reaload, its not sended again. It's confusing, because I don't have access to your code too :P
16th Jan 2017, 9:13 PM
Nahuel
Nahuel - avatar
+ 2
Sure, try to comment when its ready, so I get the notification. Night!
16th Jan 2017, 9:32 PM
Nahuel
Nahuel - avatar
+ 1
Giving a name to the submit button, and then check if it set: if(isset($_POST['subbtn'])){sqlaction}
16th Jan 2017, 8:59 PM
Nahuel
Nahuel - avatar
0
if anyone has a working code please post it in comment.
16th Jan 2017, 8:31 PM
RanjOyHunTer
RanjOyHunTer - avatar
0
Nahuel my form was submitted successfully, even the success message echoed. When the same page which was success got reloaded the data that I recently enter again got resubmitted. I am looking for an answer to prevent this. The code you mention was in my code to prevent error on first entry of form(submit button not triggered for once). So if you understand my question and have an answer please. My question seems kinda confuse.
16th Jan 2017, 9:09 PM
RanjOyHunTer
RanjOyHunTer - avatar
0
I will try your new code. I will upload my code somewhere and link it here tomorrow. Please check this post again tomorrow. I am on bed now. Thanks for the help Nahuel
16th Jan 2017, 9:19 PM
RanjOyHunTer
RanjOyHunTer - avatar