#Login Issue: existing account but incorrect password does not work

3 messages · Page 1 of 1 (latest)

sudden sleet
#

Thanks for your question :clap:, if someone gives you an answer it would be great if you thanked them with a :white_check_mark: in response. This response will earn you both points for special roles on this server.

small zealot
#

Hello,
Is there anyone can help me a bit, I've checked on database SQL and It's correct email and password for login, when I already write an email and password then it says the password is incorrect but It's not true. (no whitespacec caps lock or any other)


<?php
// Retrieve form data
$email = $_POST['email'];
$password = $_POST['password'];

// Database connection
$conn = new mysqli('localhost', 'stroox', '', 'stroox');

// Check connection
if ($conn->connect_error) {
    die('Connection Failed: ' . $conn->connect_error);
} else {

    // Check if the user exists
    $sql = "SELECT * FROM registration WHERE email = '$email'";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        // User exists, now check the password
        $row = $result->fetch_assoc();
        if (password_verify($password, $row['password'])) {
            echo "Login successful!";
        } else {
            echo "Incorrect password";
        }
    } else {
        echo "User not found";
    }

    // Close the database connection
    $conn->close();
}
?>
#

Login Issue: existing account but incorrect password does not work