尝试从堆栈溢出和互联网的各种解决方案,但似乎没有工作。我的php注册页面是一个模态窗口表单。我正在寻找的是将用户带回他重定向到登录表单的页面。
注册链接:
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-lg">SIGN UP</a>
注册处理:
<?php
ob_start();
session_start();
require_once("config.php");
require_once("all_functions.php");
$cust_email = stripslashes($_POST['cust_email']);
$cust_password = stripslashes($_POST['cust_password']););
$res = mysql_query("SELECT * FROM register WHERE cust_email = '$cust_email'");
if (mysql_num_rows($res)>0)
{
echo 'That email is already registered';
exit;
}
mysql_query("INSERT INTO register (`cust_email`, `cust_password`)
VALUES
('$cust_email', '$cust_password')");
$_SESSION['valid_user'] = $cust_email;
header("Location: http://tre.com/");
exit;
?>
检查用户是否登录的功能
<?php
function check_valid_user()
// see if somebody is logged in and notify them if not
{
global $_SESSION;
if (isset($_SESSION['valid_user']))
{
return $_SESSION['valid_user'];
}
else
{
return false;
}
}
?>
答案 0 :(得分:1)
您可以使用$_SERVER['HTTP_REFERER']
获取用户注册地址,并以上述任何一种方式应用该地址
直接将用户从注册表中恢复到上一页,而不使用任何消息
header("Location:" . $_SERVER['HTTP_REFERER']);
但如果您想显示消息,可以使用此代码
echo '<meta http-equiv=REFRESH CONTENT="0; url='.$_SERVER['HTTP_REFERER'].'">
Your registration was sucessfull you will be redirected automatically. If not, please <a href="'.$_SERVER['HTTP_REFERER'].'">click here</a>.';
希望有所帮助
答案 1 :(得分:0)
试试这个:
header('Location: ' . $_SERVER['HTTP_REFERER']);