Thứ Năm, 1 tháng 12, 2016

PHP prevent form resubmit - SOLVED

Detail: Form submit. Page reload -> form resubmit again. I did take 3 days to find on google and SOLVED. So thanks all.
Solution: catch session at Server

CODE:
Server PHP
if (isset($_POST['formid']) && isset($_SESSION['formid']) && $_POST["formid"] == $_SESSION["formid"])
{
$_SESSION["formid"] = '';
$isFirstSubmit = true;
}else{
$isFirstSubmit = false;
}
/*FormSession validate submit*/
$_SESSION["formid"] = md5(rand(0,10000000));

At Form Add 
<form>
<input type="hidden" name="formid" value="<?php echo htmlspecialchars($_SESSION["formid"]); ?>"/>
</form>