PHP detect if page is reloaded with PHP_SELF
Posted
by FFish
on Stack Overflow
See other posts from Stack Overflow
or by FFish
Published on 2010-05-19T22:04:19Z
Indexed on
2010/05/19
22:10 UTC
Read the original article
Hit count: 133
I have a form that reloads the page with the updated data:
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
...
<input type="submit" name="Submit" value="Update data">
</form>
When the page is updated I want to display a message "Data updated". There was something like this with Referer I beleve, but can't remember.
btw I am also using:
if (isset($_POST['Submit'])) {
// prevent resending data
header("Location: " . $_SERVER['PHP_SELF']);
}
to avoid the annoying resending data message when the user clicks the back button. Is this correct?
© Stack Overflow or respective owner