在 php 中附加后退按钮的链接
有什么方法可以将浏览器的后退按钮附加到任何特定链接吗?
实际上我正在用 PHP 设计一个登录页面。登录后,我希望浏览器的后退按钮打开我想要的任何特定页面,如何在 PHP 中做到这一点?
实际上我不是 PHP 专家,所以我的问题对某些人来说可能听起来很愚蠢。 :P
Is there any way by which I can attach the back button of my browser to any particular link?
Actually I am designing a login page in PHP. After login I want the back button of my browser to open any particular page that I want, how can I do that in PHP?
Actually I am not a PHP guy, so my question might sound silly to some. :P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑您想在用户登录后将其重定向到特定页面,您只需使用
header
函数即可:这会将主页重定向到
user-panel.php
页面。浏览器的后退按钮会返回,直到找到历史记录,只是补充一点,您可以使用 javascript,尽管您的情况可能不需要这样做:
更多信息请点击此处
根据评论更新:
基本上,您在用户首次进行身份验证时设置会话,这是一个例子:
I suspect you want to redirect the user to a particular page after he logs in, you can simply use the
header
function for that:That will redirect home to
user-panel.php
page.The browser's back button goes back until there is history found, just to add that you can use javascript for that although this might not be required in your case:
More info here
Update Based On Comment:
Basically you set a session when the user is authenticated for the first time, here is an example:
正如 @Sarfraz 正确所说的那样
header
是正确的选择。后退按钮位于浏览器上。 PHP 在服务器上运行,它确实知道客户端浏览器中发生的情况。该页面也可能是从 shell 访问的,例如,您没有后退按钮。此外,这也不是一个好的页面设计,因为人们希望页面在登录后自动重定向,而不必按后退按钮。
As @Sarfraz correctly says
header
is the way to go. The back button is on the browser. PHP runs on the server, it does know anything about what happens in the client's browser. The page may as well have been accessed from a shell, for instance, where you have no back button.Also, that would not be good page design, as people expect the page to rediret automagically after a login, not to have to push the back button.