I am authorizing users and I can not understand what the error is? I rewrote the code a hundred times - always the same error - Invalid login or password, although that's right!

<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("iv-data") or die(mysql_error()); if(isset($_POST["submit"])) { $user_login = strtolower(mysql_real_escape_string(trim($_POST["user_login"]))); $user_password = mysql_real_escape_string(md5(md5(trim($_POST["user_password"])))); $query = mysql_query("SELECT * FROM users WHERE user_login='$user_login'"); $user_data = mysql_fetch_array($query); if($user_data["user_password"] == $user_password){ echo "Вы вошли"; }else{ echo "Неверный логин или пароль"; } print_r($user_data); } ?> <form action="" method="POST"> <input type="text" name="user_login"> <input type="password" name="user_password"> <input type="submit" name="submit"> </form> 
  • phpfaq.ru/debug Check what is in the variable and the cell of the array when comparing, from here and make a conclusion where the error is. Ps. And another thing: why are you pulling everything out of the database when you only need a password? - andreyqin
  • Request changed, revised - everything seems to be right ... - Anoki
  • What does "revised code" mean? Results to the studio: $ user_password = mysql_real_escape_string (md5 (md5 (trim ($ _ POST ["user_password"]))))); print_r ($ user_password); / * ... * / $ user_data = mysql_fetch_array ($ query); print_r ($ user_data); - user6550
  • And yet - I am intuitively confused by this: $ user_login = strtolower (...) With the right architecture, this should not be, but should be: ... WHERE LOWER (user_login) = LOWER ('$ user_login') (well, if do not find fault with the absence of placeholders) - user6550
  • Thank you, I will take into account) Here is the result of the associative array: cs608826.vk.me/v608826628/ac29/7puU27szIiQ.jpg If I send empty data, it turns out that: cs608826.vk.me/v608826628/ac30/Dnq7BXTe9MY.jpg -yo - chp882662828 / ac30 / Dnq7BXTe9MY.jpg -ch -y - chp8756 -vp.jp

0