【问题标题】:logging out user with logout button will not redirect keeps going to php file instead of index使用注销按钮注销用户将不会重定向继续转到 php 文件而不是索引
【发布时间】:2019-06-12 00:45:07
【问题描述】:

所以我试图注销我的用户并将他们返回到主屏幕,但我只是被重定向到我的 logout.php 文件(白屏)这里的任何帮助都是代码:

(logout.php 文件)

<?php
session_Start();

unset($_SESSION['user_id']);
header("location../index.php");

?>

按钮:

<li class="nav-item">
                        <?php if(isset($_SESSION['user_id'])): ?>
                        <a href="logout.php" class="nav-link btn-success logout-btn">Logout</a>
                        <?php endif; ?>
                    </li>

尝试了很多不同的东西,但没有任何效果 我希望被重定向到 index.php 登录屏幕

【问题讨论】:

    标签: php html


    【解决方案1】:

    因为位置标头格式错误,所以浏览器不会跟随它。试试:

    header("Location: ../index.php");
    

    【讨论】:

    • @Ghost:你打开错误报告了吗?检查 PHP 错误日志?添加输出以确认代码是否已执行?
    猜你喜欢
    • 2014-07-23
    • 2016-01-21
    • 2014-06-07
    • 2011-06-15
    • 2013-02-15
    • 2017-07-06
    • 2010-09-29
    • 2021-06-15
    相关资源
    最近更新 更多