Do not submit same data twice php -
how check in php if exact same data has not been sent?
this prohibit users (accidently) sending contact form twice same data on website!.
thanks!
you can example serialize form data , store in session variable. upon receiving form data, first check if same data present in session. can add random number form hidden input field stored in $_session["rand"]. upon first submit, random number checked equality , removed (or changed) in session array. way, single form can used once, upon second submit, number different , not accepted anymore.
when generating form:
$_session["rand"] = rand();
and add in form:
<input type='hidden' name='rand' value='{$_session["rand"]}' />
upon receiving, check:
if ( $_session["rand"] === $_post["rand"]) { $_session["rand"] = false; // continue stuff...
of course, layout, single user can open single form @ same time, since opening second form overwrite random number. better approach create individual session key , value combination each form, 2 forms not overwrite each other.
Comments
Post a Comment