This question has already been answered:
- Authorization not working 3 replies
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); ?>