-1

I am using an html form , php , mysqli to save information . My form is working good but after clicking on submit button if i m refreshing the page then my mysql is saving values again and agian . what to do to stop this?

my code part

 public function registration($name,$email,$en_pass)
    {
    $sql="INSERT INTO register_user (register_name, register_mail, register_password) VALUES ('$name', '$email' ,'$en_pass')";
    if( mysqli_query($this->con, $sql))
    {
     echo "Registration successfull. Wait for approvel.";
    }   
  • Add tokens to each request (post/get values and session) and unset session value after success and if the value isn't in session/get/post don't execute register – Class Apr 23 '14 at 06:11

1 Answers1

2

You can redirect to some page after processing the form :

header('Location:nextpage.php');

That would redirect you back to the form page, and if you refresh, the browser wont resend the form data.

Rakesh Shetty
  • 4,548
  • 7
  • 40
  • 79