1

登录后如何http_referer在我的页面中设置我的位置logout.php(使用signin.php)检查并成功登录重定向到我提供注销链接(使用href)的joomla.php现在我想点击注销并转到`登录。php & 我得到 http_referer 是 joomla.php 所以我可以设置 logout.php

  1. 代码:Signin.php

    $referer = $_SERVER['HTTP_REFERER'];
    echo $referer;
    if ($referer == 'http://localhost/MinProject/reg.php')
    {
        echo "Registration SuccessFully";
    }
    
    else if($referer=='http://localhost/MinProject/changepassword.php')
    {
        echo"Change Password SuccessFully";
    }
    
  2. joomla.php

    <html>
        <body>
            <table width="100%">
                <tr>
                    <td width="20%" height="32" align="right" class="unm">
                        <?php
                        session_start();
                        if(isset($_SESSION['username']))
                        {
                            $name =$_SESSION['username'];
                            echo "Welcome ".$name;
                         }
                        ?>
                    </td>
                    <td width="64%" height="32" align="right">
                        <a href="changepassword.php">ChangePassword</a>
                    </td>
                    <td width="10%" align="right">
                        <a href="logout.php">logout</style></a>
                    </td>
                    <td width="11%"></td>
                    <td width="5%"></td>
                    <td width="5%"></td>
                    <td width="5%"></td>
                </tr>
            </table> 
        </body>
    </html>
    
  3. 注销.php

    session_start();
    unset($_SESSION['username']);
    session_destroy();
    response.setHeader("Location: http://localhost/MinProject/logout.php");
    header("Location: Signin.php");
    exit();
    
4

1 回答 1

0

HTTP_REFERER 可以被欺骗,所以你不应该使用它。

查看您的代码,我认为您正在努力实现。

$Message  = $_SESSION['MESSAGE'];//set the message Registration SuccessFully if registration else set it as Change Password SuccessFully or accordingly
if (isset($Message) and userhasidentity)
{
    echo $Message;
}else
{
   header('location:logout.php');
}
于 2013-02-04T08:54:29.097 回答