【问题标题】:$_SESSION['foo'] not defined allthough it should be [duplicate]$_SESSION['foo'] 未定义,尽管它应该是 [重复]
【发布时间】:2017-12-26 00:17:36
【问题描述】:

这真的很烦人,我不明白...我检查了 Isset,如果没有,那么我分配了 veraialbe.. 但是我进行了下一个检查,尽管应该设置 veriable,然后不... 为什么如果没有可验证/索引, if(!isset($_SESSION['foo'] 是否通过嘶嘶声适合,我不明白,这就是 (!isset 不是它的全部意义。无论如何,看看我的代码。可以任何人都知道为什么不设置它的原因..谢谢..

SESSION['登录'] 问题。

        if ($_SESSION['homepage']='001') {$_SESSION['message']==$_SESSION['message']; unset($_SESSION['homepage']);} // if message comes from anything other than the login post

        (!isset($_SESSION['homepage'])) { $_SESSION['message']==$_SESSION['message']}; // if message comes from anything other than the login post

        if (isset($_SESSION['loggedin'])) {$_SESSION['loggedin']=$_SESSION['loggedin'];} else {$_SESSION['loggedin=']='000';} 

if (!isset($_SESSION['loggedin'])) {$_SESSION['loggedin']='000';}

        if (!isset($_SESSION['message'])) { $_SESSION['message']='Please Log into an Account';}



if (isset($_POST['email'])) {
unset($_POST['email']);
unset($_POST['confirmemail']);
unset($_POST['password']);
unset($_POST['confirmpassword']);
}
    else
    if (isset($_POST['email'])) {
    unset($_POST['email']);
    unset($_POST['confirmemail']);
    unset($_POST['password']);
    unset($_POST['confirmpassword']);
    }
        else
        if (isset($_POST['confirmemail'])) {
        unset($_POST['email']);
        unset($_POST['confirmemail']);
        unset($_POST['password']);
        unset($_POST['confirmpassword']);
        }
            else
            if (isset($_POST['confirmpassword'])) {
            unset($_POST['email']);
            unset($_POST['confirmemail']);
            unset($_POST['password']);
            unset($_POST['confirmpassword']);
            };


          ........THROWS index not defined here......
if (!isset($_SESSION['loggedin'])) 
{$_SESSION['loggedin']=='000'; 
$_SESSION['message'] = 'You are NOT Logged into your account <br> Please Log in';}

【问题讨论】:

    标签: php indexing isset


    【解决方案1】:
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
    
            if ($_SESSION['homepage']='001') {$_SESSION['message']==$_SESSION['message']; unset($_SESSION['homepage']);} // if message comes from anything other than the login post
    
            (!isset($_SESSION['homepage'])) { $_SESSION['message']==$_SESSION['message']}; // if message comes from anything other than the login post
    
            if (isset($_SESSION['loggedin'])) {$_SESSION['loggedin']=$_SESSION['loggedin'];} else {$_SESSION['loggedin=']='000';} 
    
            if (!isset($_SESSION['message'])) { $_SESSION['message']='Please Log into an Account';}
    
        } else { $_SESSION['loggedin=']='000'; $_SESSION['message']='Please Log into an Account'; }
    
    
    
    if (isset($_POST['email'])) {
    unset($_POST['email']);
    unset($_POST['confirmemail']);
    unset($_POST['password']);
    unset($_POST['confirmpassword']);
    }
        else
        if (isset($_POST['email'])) {
        unset($_POST['email']);
        unset($_POST['confirmemail']);
        unset($_POST['password']);
        unset($_POST['confirmpassword']);
        }
            else
            if (isset($_POST['confirmemail'])) {
            unset($_POST['email']);
            unset($_POST['confirmemail']);
            unset($_POST['password']);
            unset($_POST['confirmpassword']);
            }
                else
                if (isset($_POST['confirmpassword'])) {
                unset($_POST['email']);
                unset($_POST['confirmemail']);
                unset($_POST['password']);
                unset($_POST['confirmpassword']);
                };
    
    
    
    if (!isset($_SESSION['loggedin'])) 
    {$_SESSION['loggedin']='000'; 
    $_SESSION['message'] = 'You are NOT Logged into your account <br> Please Log in';}
    

    我是 == 而不是 = 。另外,我添加了一个检查是否发布。感谢您的审核。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-06
      • 2013-11-16
      • 1970-01-01
      • 2021-09-11
      • 2021-02-21
      • 1970-01-01
      • 1970-01-01
      • 2019-03-12
      相关资源
      最近更新 更多