DO NOT show Alert messeger when reloading the page

Asked

Viewed 81 times

0

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

  • 1

    Hello Larissa. Welcome to Sopt. Only with this data it is not possible to help you. Could you post the source code of your website? At least the javascript part. You probably have some Alert in the page load. Taking advantage, I advise you to do a [tour] on our site to see how to work. And, whenever possible, post a [mcve] of your problem. This way is much easier to help...

2 answers

0

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

0

Well, I don’t know how you are doing this reload, 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 Validei if the post is equal to the previous one 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;
   }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.