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.
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>