This question has already been answered:

I'm just learning, the first time I do registration and authorization. Registration works fine, there is a problem with authorization. It should verify the password that the user entered into the database. If, before checking, to display both values, it is clear that the password from the database is not issued, so the authorization does not pass. Tell me what's wrong:

<?php // ПЕРЕВІРКА mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $connect = mysqli_connect ("localhost","root","vertrigo","my_bd"); if (!$connect) { mysqli_error(); } if (isset($_POST['register'])) { $login = $_POST['login']; $pswd = $_POST['pswd']; $pswd_again = $_POST['pswd_again']; $user_name = $_POST['user_name']; $user_surname = $_POST['user_surname']; $user_age = $_POST['user_age']; $user_origin = $_POST['user_origin']; $result = mysqli_query($connect, "INSERT INTO users (login, password, name, surname, age, origin) VALUES ('$login','$pswd','$user_name','$user_surname','$user_age','$user_origin')"); } mysqli_close($connect); // ПРОВЕРКА 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 = $_POST['enter_pswd']; $sql = mysqli_query($connect, " SELECT * FROM users WHERE 'login' = '$enter_login' "); $user_data = mysqli_fetch_array($sql); echo $user_data['password']; //echo $user_data ['password']; //echo $enter_pswd; if ($user_data['password'] == $enter_pswd) { echo 'HELLO HELLO HELLO HELLO HELLO'; } } mysqli_close($connect); ?> 

Reported as a duplicate by members of Visman , aleksandr barakin , cheops , Grundy , Denis on Oct 29 '16 at 16:20 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    mysqli_fetch_array array returns.

    So, it is necessary:

     if ($user_data[0]['password'] == $enter_pswd) { echo 'HELLO HELLO HELLO HELLO HELLO'; } 
    • did not help. 'HELLO HELLO HELLO HELLO HELLO' does not display - user225682