I have a simple form that submits text to my SQL table. The problem is that after the user submits the text, they can refresh the page and the data gets submitted again with
You can prevent form resubmission via a session variable.
First you have to set rand()
in a textbox and $_SESSION['rand']
on the form page:
After that check $_SESSION['rand']
with textbox $_POST['randcheck']
value
like this:
if(isset($_POST['submitbtn']) && $_POST['randcheck']==$_SESSION['rand'])
{
// Your code here
}