1

从堆栈溢出和互联网尝试了各种解决方案,但似乎没有一个有效。我的 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;
}
}
?>
4

2 回答 2

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>.';

希望有帮助

于 2013-08-11T06:54:53.553 回答
0

尝试这个:

header('Location: ' . $_SERVER['HTTP_REFERER']);
于 2013-08-11T06:02:33.163 回答