[英]How i get the url from the last page visited php?
My problem is that, I have a table with values, when I pulse on one of the cells redirect to a cell details page, in the url I pass the id: "http://localhost/example?id=123456".我的问题是,我有一个带有值的表,当我在其中一个单元格上进行脉冲重定向到单元格详细信息页面时,在 url 中,我传递了 id:“http://localhost/example?id=123456”。 when I back to the previous page with a cancel or save button does redirect to the previous page and get in id with
$_SERVER['HTTP_REFERER']
but when you pulse the back button in the browser I don't know how to get that url.当我使用取消或保存按钮返回上一页时,会重定向到上一页并使用
$_SERVER['HTTP_REFERER']
进入 id 但是当您在浏览器中按下后退按钮时,我不知道如何获取url。
You can use the session system of PHP:可以使用PHP的session系统:
$_SESSION['page'] = $_SERVER['HTTP_REFERER'];
To redirect to the last page you can use the header function.要重定向到最后一页,您可以使用 header function。
header("Location: ".$_SESSION['page']);
exit();
On the server-side using $_SERVER['HTTP_REFERER']
is enough and you don;t need to store the value of $_SERVER['HTTP_REFERER']
on $_SESSION
too.在服务器端使用
$_SERVER['HTTP_REFERER']
就足够了,您也不需要在$_SESSION
上存储$_SERVER['HTTP_REFERER']
的值。 just directly check the $_SERVER['HTTP_REFERER']
val.只需直接检查
$_SERVER['HTTP_REFERER']
val。
For the client-side, you can use document.referrer
in JS.对于客户端,您可以在 JS 中使用
document.referrer
。 Also, it can be helpful for you to know these functions in JavaScript:此外,了解 JavaScript 中的这些功能对您会有所帮助:
history.back(); //Go to the previous page
history.forward(); //Go to the next page in the stack
history.go(index); //Where index could be 1, -1, 56, etc.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.