0

I have this problem where when I refresh, a notification box will pop up in the browser(Chrome) just like this.

enter image description here

my code for the sign in is here:

<form class="uk-form">
    <fieldset data-uk-margin>
        <legend>Sign up here:</legend>
        <input type="text" placeholder="username" required>
        <input type="password" placeholder="password" required>
        <a href="" class="uk-form-password-toggle" data-uk-form-password></a>
        <select>
            <option>PYP</option>
            <option>MYP</option>
            <option>DP</option>
            <option>Adults/Teachers</option>
        </select>
        <div><input type="checkbox" name="remember" id="remember" <?php if(isset($_COOKIE["member_login"])) { ?> checked <?php } ?> />
            <label for="remember-me">Remember me</label>
        </div>
        <button type="confirm" class="uk-button uk-button-primary">Sign Up</button>
    </fieldset>
</form>

and the result is this:

enter image description here

Dave
  • 5,108
  • 16
  • 30
  • 40
andy zhang
  • 21
  • 6
  • There's a detailed answer here for you https://stackoverflow.com/questions/6833914/how-to-prevent-the-confirm-form-resubmission-dialog?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Andrew Schultz Apr 07 '18 at 07:24
  • 1
    Possible duplicate of [How to prevent the "Confirm Form Resubmission" dialog?](https://stackoverflow.com/questions/6833914/how-to-prevent-the-confirm-form-resubmission-dialog) – Dave Apr 07 '18 at 09:37

3 Answers3

1

This is occurring because you previously POSTed to that page, meaning that you've most likely come from a form. If you refresh the page it means the POST data will be posted again to that page which is probably not what you want to do.

My advice would be once you've done what you need to do with the form, is to redirect it to another page (could in theory be back to the form page) and repopulate the data if you need to keep it.

Simon R
  • 3,732
  • 4
  • 31
  • 39
0

After processing the $_POST data on the previous request you can redirect the user, and clear the Post data by doing this:

header('Location: '.$url);
exit;

Where $url is set to the URL you want to send them to. There are 2 very important things if you do this.

  1. You cannot output anything before calling header, not even 1 single space.

Coincidentally this is why you will see some PHP files that do not include a ?> closing tag. The closing tag is optional if the file only contains PHP, and even a space after the end tag can mess up redirect if it was included before calling them. So by omitting the end tags, there can be no output.

Conciser this:

<?php

   ...code..
?>
\n

Where \n is a new line. If this is included before doing a header or even a download it can have undesirable effects. Personally I never mix PHP and HTML and so I never use the end tags.

Likewise this can prevent the redirect from working

\n
<?php
 ... code ...
  1. You call exit immediately following the redirect. After doing the redirect PHP will continue to execute the current script, which is probably not what you want and can have unpredictable results.
ArtisticPhoenix
  • 21,464
  • 2
  • 24
  • 38
0

It's happend because you come from another form that send POST. When you refresh, it will confirm you that data have been posted before will posted again. I advice you redirect to another page or same page. Read header in php to redirect

dedy
  • 36
  • 5