This question already has an answer here:
- check if row exists with mysql 3 answers
I have a table of users in the database, each user has an id, firstname, lastname, username and a password attribute.
I am trying to create a simple login page and I need to check if the entered password is correct for entered username.
My query looks like that:
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset("utf8");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = 'SELECT password FROM users WHERE username = "something"';
$result = $conn->query($sql);
Query should return a password for a specified user but I don't know how to get it.
$result->fetch_array()
returns nothing in my case.
</div>