How can user return to the page he came from, and refresh its content, using PHP or javascript.
I've used this to get back to the page :
header("Location: javascript:history.back(-1)");
but it needs to be refreshed after that.
You cannot execute javascript in a PHP script.
In PHP you can make use of the $_SERVER["HTTP_REFERER"]
variable in the header()
statement like so
header('Location: ' . $_SERVER["HTTP_REFERER"] );
exit;
Its always a good idea to follow a header()
statement with an exit
or code execution will continue through the rest of the script as normal.
If you just want to use javascript you can use window.history.back()
function goBack() {
window.history.back();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.