0

This question has been asked alot so I found this article Allowing users to Refresh browser without the "Confirm Form Resubmission" pop-up

And I follow what it said but now i'm getting this message 500: Internal Error.

So what i'm I doing wrong here? I basically want be able to refresh a page with out getting greeted with this message

Confirm For Resubmission The page that you're looking for used information that you entered. Returning to that page might cause any action you took to be repeated. Do you want to continue?

because of a form and I all so checked this out to Preventing form resubmission

I try to understand these guys answers but i'm still not getting something right if any one can show me the two so called poplar methods mentioned in the links by using the PHP method or the AJAX with jQuery method to prevent that confirm for resubmission message I will really appreciate that. Please I prefer code solutions based on my code as answers because I personally learn best that way thank you.

GIF Screenshot

code

index.php

    <!DOCTYPE html>
    <html>
      <head>
        <style>
          *, *:before, *:after {
      -moz-box-sizing: border-box;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
    }

    body {
      font-family: 'Nunito', sans-serif;
      color: #384047;
    }

    form {
      max-width: 300px;
      margin: 10px auto;
      padding: 10px 20px;
      background: gold;
      border-radius: 8px;
    }

    h1 {
      margin: 0 0 30px 0;
      text-align: center;
    }

    input[type="text"] {
      background: rgba(255,255,255,0.1);
      border: none;
      font-size: 16px;
      height: auto;
      margin: 0;
      outline: 0;
      padding: 15px;
      width: 100%;
      background-color: white;
      color: black;
      box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
      margin-bottom: 30px;
    }


    button {
      padding: 19px 39px 18px 39px;
      color: #FFF;
      background-color: blue;
      font-size: 18px;
      text-align: center;
      font-style: normal;
      border-radius: 5px;
      width: 100%;
      border: 1px solid blue;
      border-width: 1px 1px 3px;
      box-shadow: 0 -1px 0 rgba(255,255,255,0.1) inset;
      margin-bottom: 10px;
      cursor: pointer;
    }

    label {
      display: block;
      margin-bottom: 8px;
    }

    label.light {
      font-weight: 300;
      display: inline;
    }

</style>
      </head>
      <body>
    <form action='x.php' method='POST'>
      <h1>Form</h1>
      <label for='name'>Name</label>
      <input type='text' id='name' name='name' value='Tom'>
      <label for='age'>Age</label>
      <input type='text' id='age' name='age' value='20'>
      <button type='submit'>Send</button>
    </form>
      </body>
    </html>

x.php

<?php

if($_SERVER['REQUEST_METHOD'] == "POST"){ header('x.php'); }

$name = $_POST['name'];
$age = $_POST['age'];

?>

<p><?php echo $name; ?></p>
<p><?php echo $age; ?></p>

1 Answers1

0

I changed your code a bit, but should produce the result that you want

<?php
    if(isset($_POST['submit'])){
        header('Location: x.php?successfulRedirect');
        exit;
    }
?>
<form action='' method='POST'>
    <h1>Form</h1>
    <label for='name'>Name</label>
    <input type='text' id='name' name='name' value='Tom'>
    <label for='age'>Age</label>
    <input type='text' id='age' name='age' value='20'>
    <input type='submit' name='submit' value='Send' />
</form>

This will make sure that you will be redirected to x.php after clicking Send, with a GET parameter it in, just to see that the redirection works

Carl Binalla
  • 5,393
  • 5
  • 27
  • 46
  • I did test it out and I told you about the errors the page kept looping and causing errors I have not lost respect for you I really appreciate your effort I really do but it is up to you if you want to move on to a new question of another user I'll figure it out in time thanks.... –  Oct 18 '17 at 08:37
  • Please tell me whether you update the docs. You said it kept looping, but the docs says another error. Your goal is to remove the alert while displaying the values right? – Carl Binalla Oct 18 '17 at 08:43
  • Thanks for your response I will try it as soon as I wake up I have to sleep now so I will talk to you later ok have a good night since it's night where I live at. –  Oct 18 '17 at 09:09