It does not generate errors, but does not display echo.

// ПРОВЕРКА mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $connect = mysqli_connect ("localhost","root","vertrigo","my_bd"); if (!$connect) { mysqli_error(); } if (isset($_POST['enter'])) { $enter_login = $_POST['enter_login']; $enter_pswd = md5($_POST['enter_pswd']); $sql = mysqli_query($connect, " SELECT * FROM users WHERE 'login' = '$enter_login' "); $user_data = mysqli_fetch_array($sql); if ($user_data['password'] == $enter_pswd) { echo 'HELLO HELLO HELLO HELLO HELLO'; } } mysqli_close($connect); 

    3 answers 3

    If nothing is displayed, there is a connection to the database, but the condition is not met.
    if ($user_data['password'] == $enter_pswd)
    Try to check two variables before checking (the expression is written above) and see what is in them
    echo $user_data['password']
    echo $enter_pswd

    • there is little data, but note that after the password that comes from the form is processed by the md5 function, and in your database, in what form is the password stored? - Konstantin
    • removed md5 everywhere, before you check two passwords: echo $ user_data ['password'] echo $ enter_pswd, from which $ user_data ['password'] is simply not output. The other that we enter into the form displays. - user225682
    • + tried to create a user through phpmyadmin the same situation, I wanted to check if the data is not correctly transmitted during the registration process - user225682
    • It is necessary to use the documentation. the mysqli_query () function returns false in case of failure, if the request has fulfilled it returns result, and for all other cases it returns true. Therefore, try to write like this: <br/> echo $sql = mysqli_query($connect, " SELECT * FROM users WHERE 'login' = '$enter_login' "); and see the result, it will immediately become clear what the problem is - Konstantin
    • Error: Object of class mysqli_result could not be converted to string. - user225682

    Add a line with debug output and everything will become clear.

     $user_data = mysqli_fetch_array($sql); echo $user_data['password'], ' - ', $enter_pswd; // ДОБАВИТЬ ЭТУ СТРОКУ if ($user_data['password'] == $enter_pswd) { 

    And further

     $sql = mysqli_query($connect, " SELECT * FROM users WHERE 'login' = '$enter_login' "); 

    SQL injection

      Problem solved! An error was made in the syntax:

      So correct: $ sql = mysqli_query ($ connect, "SELECT * FROM users WHERE login = '$ enter_login'");

      This is not correct: $ sql = mysqli_query ($ connect, "SELECT * FROM users WHERE 'login' = '$ enter_login'");