DO NOT show alert messeger when reloading page

0

I'm creating a control page for my site, but when the page is reloaded I always get an alert asking if I'd like to resend used parameters. I would like to know how to remove this alert or send your confirmation automatically.

    
asked by anonymous 29.04.2017 / 01:19

2 answers

0

If I understand what is happening is that you used a form with the method post and for the page in which it was sent try to reload it, if what I understood is correct, this is a browser action because in HTTP headers it will send to the server is a header with method post and it reconfirms the sending of the same data used previously.

    
29.04.2017 / 03:05
0

Well, I do not know how you are performing this reloading, but if it is automatic by the system, send via get passing url, I had this problem with the user giving F5 to reload the page, to solve validated if the post is equal to previous it returns the page via url:

if($_SERVER['REQUEST_METHOD'] == 'POST') {
   $request = implode($_POST);
   if(isset($_SESSION['last_request']) && ($_SESSION['last_request'] == $request)) {
      header("Location:".$url); 
      exit;
   }else {
      $_SESSION['last_request'] = $request;
   }
}
    
29.04.2017 / 15:47