0

How to stop Postback form submissions in PHP

Spread the love

When I was new to Programming and was not so familiar with Form Post backs it was a headache for me because Sometimes user may hit submit button twice or user may reload the page(with post data), This both activities make form processing multiple times with same data,this results duplicate records in DB or duplicate Emails in the Inbox.

stop postback form submissions in php and mysql ,stop postback form submissions in php box ,stop postback form submissions in php code ,stop postback form submissions in php date ,stop postback form submissions in php download ,stop postback form submissions in php example ,stop postback form submissions in php form ,stop postback form submissions in php free download ,stop postback form submissions in php group ,stop postback form submissions in php java ,stop postback form submissions in php javascript ,stop postback form submissions in php jquery ,stop postback form submissions in php key ,stop postback form submissions in php language ,stop postback form submissions in php laravel ,stop postback form submissions in php list ,stop postback form submissions in php mysql ,stop postback form submissions in php not working ,stop postback form submissions in php online ,stop postback form submissions in php page ,stop postback form submissions in php pdf ,stop postback form submissions in php pdo ,stop postback form submissions in php query ,stop postback form submissions in php quiz ,stop postback form submissions in php rate ,stop postback form submissions in php test ,stop postback form submissions in php tutorial ,stop postback form submissions in php version ,stop postback form submissions in php video ,stop postback form submissions in php view ,stop postback form submissions in php xamarin ,stop postback form submissions in php xampp ,stop postback form submissions in php xml ,stop postback form submissions in php y mysql ,stop postback form submissions in php youtube ,stop postback form submissions in php zero ,stop postback form submissions in php zte

To escape this behavior in PHP I started to include a unique token on each post request. this method is also useful to prevent CSRF and replay attacks. I generated unique key in hidden filed ( <input type=”hidden” /> ) in form and also in session variable. Once the form is submitted i compared hidden field value with session token value, if both values matched then the form submission is valid ,if token does not match the token in our session , the form has been re-submitted.

So now below you can check my code :

PHP Code

Create a hidden Field

Complete Example

Hope it will Help You and please like my facebook page :

and make me proud.By the way if you face any problem then let me know in comment section below

Leave a Reply

Your email address will not be published. Required fields are marked *