嘿,每个人都完成了我的研究,我发现我仍然坚持很多人说要在变量前加上 @ 符号,但它似乎不起作用,所以我的代码给了我这个错误
                 Notice: Undefined index: 2 in login.php on line 20
我的代码是
          if( isset($_REQUEST['email']) || isset($_REQUEST['pwd']) || $_REQUEST['email'] != "" || $_REQUEST['pwd'] != "" )
                    {
                          $inputFile = fopen("members.txt", "r");  
                          $found = false;
                          $i =0;
                          //read the read.txt until the end of file
                          while(!feof($inputFile) && $found == false)  
                          {
                            $line = fgets($inputFile);  
                            // replace the special charater within the lines by there proper entity code
                            $lineArray = preg_split("/\,/", (string)$line);
                            if ($_REQUEST['email'] === $lineArray['2'] && $_REQUEST['pwd'] === $lineArray['4']) 
                            {
                                        session_start();
                                        $found = true;
                                        $useremail=$_REQUEST['email'];
                                        $password= $_REQUEST['pwd'];
                                        //time to set sessions and stuff
                                        $_SESSION['useremail'] = $useremail;
                                        $_SESSION['password'] = $password;
                                        //send the redirect header
                                        header('Location: index.php');
                                        exit();
                            }
                          }
                          fclose($inputFile);
                    }
所以它所指的线是
                            if ($_REQUEST['email'] === $lineArray['2'] && $_REQUEST['pwd'] === $lineArray['4']) 
我尝试了许多其他变体,例如删除单引号在 $lineArray 前面添加 @ 并同时执行这两种操作,任何人都可以帮我找出当我打印它们时的值,但是当它到达这个 if 语句时它不会转动相等,它给了我这个错误。
如果也尝试过
           if ($_REQUEST['email'] === $lineArray[2] && $_REQUEST['pwd'] === $lineArray[4]) 
和
        if ($_REQUEST['email'] === @$lineArray[2] && $_REQUEST['pwd'] === @$lineArray[4])