首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >没有显示成功消息,也没有将url重定向到activate.php?success。

没有显示成功消息,也没有将url重定向到activate.php?success。
EN

Stack Overflow用户
提问于 2013-01-31 14:54:28
回答 3查看 1K关注 0票数 0

我很难在PHP用户/注册站点上找出一个错误。注册后,使用激活链接发送电子邮件,当单击该链接时,它将成功激活帐户,但它没有显示成功消息。

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

激活链接如下所示:

http://website.com/activate.php?email=useremail@website.com&email

这是我的activate.php代码

代码语言:javascript
复制
<?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'; ?>

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

网址不更改:code=2631df446b129480abdbf54f08e8c494

到:website.com/activate.php?成功

EN

Stack Overflow用户

发布于 2013-01-31 15:10:44

您应该测试哪些标准不合格,请参见下面。另外,请注意:如果不传递状态,则不需要exit中的括号,也不需要打开和关闭php,这是不必要的:

代码语言:javascript
复制
<?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';

当我用?success测试上面的代码时,它为我重定向很好。

编辑:

如果我正确理解了上面关于empty($_GET['success'] == true)activate.php中的代码,那么如果它有效,您将得到一个无限的头重定向错误。你的逻辑需要重新审视。

票数 0
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14628639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档