for example the following file is SamePage.php
<!DOCTYPE html>
<html lang="en">
<head><title>Personal Information</title></head>
<body>
<?php
if(!empty($_POST))
{
echo $_POST['var'].'<br />';
//do a bunch of stuff
...
echo "Inserted into database succesfully! You will now be redirected.<meta http-equiv=refresh content=4;url=database.php><br /></body></html>";//meta refresh gets rid of old POST data
exit;
}
?>
Add another entery:<br />
<form method="POST" action="SamePage.php"><--!It sends the information to itself-->
name: <input type="text" name="name" size="10" maxlength="25" /><br />
telephone: <input type="text" name="telephone" size="10" maxlength="25" /><br />
birthday: <input type="text" name="birthday" size="10" maxlength="25" /><br />
<input type="submit" value="add" />
<input type="reset" value="clear" />
</form>
</body>
</html>
It’s not very nice to have the exit there and sometimes I don’t want to refresh the page, but it has to be done encase the user presses the refresh on the browser and the same POST data gets sent again and things get messed up. Can anyone think of a better way?
Best is to send the form to another page and the reload your page… But if you don’t want, you can: