我有以下代码将用户重定向到登录页面,如果他们还没有登录。但是我想将他们的页面重定向到他们登录后的页面,任何想法怎么做?
if(count($user)==0) redirect_page("/login.php");
答案 0 :(得分:4)
您可以将它们来自的页面路径添加到查询字符串中,如下所示:
/login.php?returnUri=/the/page/they/came/from.php
答案 1 :(得分:1)
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
来源: Back to previous page with header( "Location: " ); in PHP
答案 2 :(得分:0)
发现以下内容确实有效:
header("location:javascript://history.go(-1)");
(通过Back to previous page with header( "Location: " ); in PHP)
答案 3 :(得分:-2)
if(count($user)==0){
echo "<script>JavaScript:history.back()</script>";
}