【问题标题】:PHP logout link wrongPHP注销链接错误
【发布时间】:2016-03-09 23:15:30
【问题描述】:

我有一个注销图标。问题是,当我单击注销图标时,它会注销我,但我的注销表单的设计看起来不同,并且链接也是错误的,而不是 index.html,它在刷新后将我链接到 logout.php 我在右边小路。

我的问题可能是什么?

那是在一个 html 页面上,我将链接设置为 logout.php

<li><a href="logout.php"><i class="fa fa-sign-out"></i></a></li> 

index

这是我的 logout.php 代码

<?php
    session_start();
    session_destroy();
header("Location: index.php");
?>

logout

【问题讨论】:

    标签: php html session hyperlink path


    【解决方案1】:

    语法错误

    <?php
        session_start();
        session_destroy();
    header("Location: index.php"
    ?>
    

    缺少右括号,也许您需要将重定向更改为 index.html

    <?php
        session_start();
        session_destroy();
        header("Location: index.php"); // here maybe index.html depending where do you want to redirect 
    ?>
    

    【讨论】:

    • 哦,对不起,我的错误我只是忘记了这里的括号,但在原来的有右括号。好的,我会尝试将其重定向到 index.html
    • 不行,改重定向后问题依然存在
    • 所以等它注销后它不会将您重定向到索引页面?
    • 是的,它只是将我重定向到 logout.php 而不是 index.php
    • 看看当你点击&lt;li&gt;&lt;a href="logout.php"&gt;&lt;i class="fa fa-sign-out"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; 时可以重定向到logout.php 页面然后这部分header("Location: index.php"); 应该让你回到索引页面。请注意 index.php 或 index.html 必须存在。它无法将您重定向到不存在的页面,因此请再检查一次您希望标题返回给您的页面名称。
    猜你喜欢
    • 2012-02-15
    • 1970-01-01
    • 1970-01-01
    • 2015-02-13
    • 2019-03-22
    • 2015-02-06
    • 1970-01-01
    • 2013-02-09
    • 2021-08-19
    相关资源
    最近更新 更多