I am writing a site for self-study. At this point, I stopped at the script to enter the user's site using the "Логин" and "Пароль" fields. Everything is as it should be - a form, a script for processing this form. In general, when you click on the "Вход" button "Вход" script is processed that checks the correctness of the data (compares it with the database in which the registered users are located). In this script, first the data from the $_POST array is taken.

 $login = $_POST['login]'; $password = $_POST['password']; 

Further, this data is checked for value by the isset function:

 if(!isset($login) or !isset($password)) { exit("Пользователь с таким логином или паролем не найден"); } 

And when I click on the "Вход" button, the script ends with a message

"User with this login or password not found"

but the most interesting thing that I put in front of this condition was the output of these two variables ( $login and $password ), I got them out normally and showed just what I entered in the "Login" and "Password" fields.

What could be the problem?

I also tried instead of !isset to set empty , it still fails with the error of the existence of $login and $password variables.

I packed these two files into the archive at .
This is why it did not work

  • Give both files in the minimum variant (the form and the processor, sufficient for an error), we will think. While you can only assume (the form does not go there, variables are somewhere in the process overwritten, a typo in the end) - Sh4dow
  • I figured it out. The problem was in the Html Redirect, which stood at the bottom of the page. - Alexey Emelyanenko 7:08 pm
  • @ LehaEmelianenko, ru.stackoverflow.com/questions/239453/… - root_x Povierennyy

2 answers 2

  1. First, do not need to write "garlands" ala isset ($ a) || isset ($ b) ... || isset ($ n) ? it is enough to list them through a comma isset ($ a, $ b, ... $ c) .

  2. Secondly, the error in Korea is that the data transfer method is not specified in the form - method = "POST" .

  3. If everything is okay with step 2, then try the following:

     $login = !empty($_POST['login']) ? $_POST['login'] : null; $password = !empty($_POST['password']) ? $_POST['password'] : null; if(!isset($login,$password)){ exit('Error!'); } 
  • Displays anyway error. The form is registered <form action = "./ functions / testreg.php" method = "post"> Here are the fields <input name = "login" type = "text" size = "16" maxlength = "16"> <input name = "password" type = "password" size = "16" maxlength = "16"> <input type = "submit" name = "submit" value = "Login"> </ form> All this is written in the index.php file . - Alexey Emelyanenko
  • 2
    @Deonis you won’t believe, I didn’t know about isset($a,$b,...$c) either isset($a,$b,...$c) %) Thank you) Only he is not OR , but AND (see clause 1). - Sh4dow
  • Why fuss and empty and isset when there is just enough empty , 1 condition, for a place of 3x. - And

Maybe there is a problem in the scope of variables?