Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未显示成功消息,且url未重定向到activate.php?Success_Php - Fatal编程技术网

未显示成功消息,且url未重定向到activate.php?Success

未显示成功消息,且url未重定向到activate.php?Success,php,Php,我很难找出PHP用户/注册站点的错误。 注册后,将发送一封带有激活链接的电子邮件,单击该链接后,它将成功激活帐户,但不会显示成功消息 如果我在浏览器中复制/粘贴激活链接,并更改链接中的电子邮件或电子邮件代码中的字母,它将成功地向我发送所有错误消息 激活链接如下所示: 这是我的activate.php的代码 <?php include 'core/init.php'; logged_in_redirect(); include 'includes/overall/header.php';

我很难找出PHP用户/注册站点的错误。 注册后,将发送一封带有激活链接的电子邮件,单击该链接后,它将成功激活帐户,但不会显示成功消息

如果我在浏览器中复制/粘贴激活链接,并更改链接中的电子邮件或电子邮件代码中的字母,它将成功地向我发送所有错误消息

激活链接如下所示:

这是我的activate.php的代码

<?php 
include 'core/init.php';
logged_in_redirect();
include 'includes/overall/header.php';
?>

<?php 
if (isset($_GET['success']) == true && empty($_GET['success']) == true) {
    ?>
<h3>Thanks, your account has been activated..</h3>
<p>You're free to log in!</p>
<?php
    header('Location: activate.php?success');
    exit();
} else if (isset($_GET['email'], $_GET['email_code']) === true) {

$email      = trim($_GET['email']);
$email_code = trim($_GET['email_code']);

if (email_exists($email) === false) {
    $errors[] = 'Ooops something went wrong, and we couldn\'t find that email adress!';
    } else if (activate($email, $email_code) === false) {
    $errors[] = 'We had problems activating your account';
    } if (empty($errors) === false) {
?>
    <h2>Ooops...</h2>
<?php
    echo output_errors($errors);
} else {
    header('Location: activate.php?success');
    exit();
}
} else {
header('Location: index.php');
exit();
}
?>

<?php include 'includes/overall/footer.php'; ?>

谢谢,您的帐户已激活。。
您可以自由登录

哎呀。。。
为什么它不给我成功的信息和重定向

URL不会从以下位置更改:

致:
website.com/activate.php?success

这句话有点可疑:

if (isset($_GET['success']) == true && empty($_GET['success']) == true) {

你确定它不是
&&empty($\u GET['success'])==false)

永远不要使用HTMLcode你将它设置为if
activate==true
并将其空重定向到该页面,这样你就可以得到一个重定向循环

if (isset($_GET['success']) == true && empty($_GET['success']) == true) {
        header('Location: activate.php?success');
        exit();
}
试一试


您应该测试哪些标准不合格,请参见下文。作为旁注:您不需要
exit
中的括号,如果您没有传递状态,您也不需要频繁地打开和关闭php,这是不必要的:

<?php 
include 'core/init.php';
logged_in_redirect();
include 'includes/overall/header.php';

if (isset($_GET['success']) && !empty($_GET['success'])) {
    //in activate.php isset($_GET['success']) add this ouput, 
    //it works / not recommended and never seen.
    //echo "<h3>Thanks, your account has been activated..</h3>";
    //echo "<p>You're free to log in!</p>";
    header('Location: activate.php?success');
    exit;
} else if (isset($_GET['email'], $_GET['email_code'])) {
    $email = trim($_GET['email']);
    $email_code = trim($_GET['email_code']);
    if (email_exists($email) === false) {
        $errors[] = 'Ooops something went wrong, and we couldn\'t find that email adress!';
    } else if (activate($email, $email_code) === false) {
        $errors[] = 'We had problems activating your account';
    } if (empty($errors) === false) {
        echo "<h2>Ooops...</h2>";
        echo output_errors($errors);
    } else {
        header('Location: activate.php?success');
        exit;
    }
} else {
    // The following 2 lines: You should see 1, 0 or nothing
    // From there you should be able to troubleshoot.        
    echo "isset: ".isset($_GET['success'])."<br>";
    echo "Empty: ".empty($_GET['success']);
    //header('Location: index.php');
    exit;
}
include 'includes/overall/footer.php';

empty($\u GET['success'])==真的很抱歉,为什么要添加额外的代码?你不能只选中empty($\u GET['success'])?isset本身返回true或false不需要使用==true进行检查您可能应该使用POST,您正在使用GET共享个人信息,即使您重定向。在发送HTML之后,您无法发送标题。你必须在做任何事情之前先做标题。此外,与立即重定向不同,您应该编写5秒钟的重定向,以便用户可以阅读您的消息,告诉他们他们已激活
如果我理解正确,并且您的上述代码
为空($\u GET['success']==true)
activate.php
中,那么如果它起作用,您将得到一个无限头重定向错误。您的逻辑需要重新检查。或者更好的方法是:
(isset($\u GET['success'])&&!empty($\u GET['success'])
是的,我使用相同的方法,我只是添加了FALSE以使更改变得引人注目。输出1、0或nothing的含义是什么?我的意思是
布尔值。1为
,0为
或无,因为它没有到达那里。我的代码与返回
布尔值的
isset
相呼应
<?php 
include 'core/init.php';
logged_in_redirect();
include 'includes/overall/header.php';

if (isset($_GET['success']) && !empty($_GET['success'])) {
    //in activate.php isset($_GET['success']) add this ouput, 
    //it works / not recommended and never seen.
    //echo "<h3>Thanks, your account has been activated..</h3>";
    //echo "<p>You're free to log in!</p>";
    header('Location: activate.php?success');
    exit;
} else if (isset($_GET['email'], $_GET['email_code'])) {
    $email = trim($_GET['email']);
    $email_code = trim($_GET['email_code']);
    if (email_exists($email) === false) {
        $errors[] = 'Ooops something went wrong, and we couldn\'t find that email adress!';
    } else if (activate($email, $email_code) === false) {
        $errors[] = 'We had problems activating your account';
    } if (empty($errors) === false) {
        echo "<h2>Ooops...</h2>";
        echo output_errors($errors);
    } else {
        header('Location: activate.php?success');
        exit;
    }
} else {
    // The following 2 lines: You should see 1, 0 or nothing
    // From there you should be able to troubleshoot.        
    echo "isset: ".isset($_GET['success'])."<br>";
    echo "Empty: ".empty($_GET['success']);
    //header('Location: index.php');
    exit;
}
include 'includes/overall/footer.php';