Undefined index with PHP sessions

后端 未结 2 1484
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 12:12

I\'m new to PHP and am even more of a beginner when it comes to sessions. I have my index.php page, which is where users can register and login. The forms are posting to val

2条回答
  •  不知归路
    2020-11-29 13:08

    If you're getting undefined index errors, you might try making sure that your indexes are set before you try comparing the values. See the documentation for the isset function here: http://php.net/manual/en/function.isset.php

    if (isset($_SESSION['registered']))
      if ($_SESSION['registered'] != NULL){
          echo $_SESSION['registered'];                   
      }
    }
    if (isset($_SESSION['badlogin']))
      if ($_SESSION['badlogin'] != NULL){
          echo $_SESSION['badlogin'];
      }
    }
    if (isset($_SESSION['neverused']))
      if ($_SESSION['neverused'] != NULL) {
          echo $_SESSION['neverused'];                    
      }
    }
    

提交回复
热议问题