So I need to make a whole login system for my graduation project. I already made a database on mysql which works perfectly. The register part of the login works but if I try to login with the account I just made, it doesnt work. Most of the time I'm getting the error 'Password/e-mail is wrong' while its correct?
Thanks in advance!
<?php
include("config.php");
session_start();
$email =$_POST['email'];
$password =$_POST['password'];
if(empty($email))
{
exit();
}else {
$stmt =mysqli_stmt_init($db);
$sql = "SELECT * FROM users WHERE email=?;";
if(!mysqli_stmt_prepare($stmt, $sql))
{
echo"No data";
}else
{
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($result))
{
$combicheck = password_verify($password,$row['password']);
if($combicheck == false)
{
echo"Password / email is wrong";
exit();
}else if($combicheck == true){
session_start();
$_SESSION['password'] = $row['password'];
header('Location: index.html');
echo"Logged in";
}
}else
{
echo"Failed";
}
}
}