繁体   English   中英

用户登录后如何将用户重定向回上一页?

[英]How to redirect user back to the previous page after they login?

如果用户尚未登录,我有以下代码将用户重定向到登录页面。但是我想将他们页面重定向到他们登录后来自的页面,有什么想法要怎么做?

 if(count($user)==0) redirect_page("/login.php");

您可以将路径添加到查询字符串,例如: /login.php?returnUri=/the/page/they/came/from.php the/page/they/came/ /login.php?returnUri=/the/page/they/came/from.php

header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;

来源: 返回上一页,其标题为“(Location:“); 在PHP中

发现以下内容确实有效:

header("location:javascript://history.go(-1)");

在PHP中通过header(“ Location:”);返回上一页

if(count($user)==0){
    echo "<script>JavaScript:history.back()</script>";
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM