prepare($query);
$check = $stmt->execute($array);
if(!$check)
{
$error = "Incorrect email or password";
}
if($check)
{
$data = $stmt->fetchAll(PDO::FETCH_OBJ);
if(is_array($data) && count($data) > 0)
{
$data = $data[0];
$newpass = $data->passwd;
if(password_verify($passwd, $newpass))
{
$passwd = $newpass;
}
}
else
{
$error = "Incorrect email or password";
}
}
}
if($error == "")
{
$array['email'] = $email;
$array['passwd'] = $passwd;
$query = "select * from users where email = :email && passwd = :passwd limit 1";
$stmt = $con->prepare($query);
$check = $stmt->execute($array);
if($check)
{
$data = $stmt->fetchAll(PDO::FETCH_OBJ);
if(is_array($data) && count($data) > 0)
{
$data = $data[0];
$_SESSION['firstName'] = $data->firstName;
$_SESSION['urlAddress'] = $data->urlAddress;
$_SESSION['userID'] = $data->userID;
header("Location: index.php");
die;
}
else
{
$error = "Incorrect email or password";
}
}
}
}
$_SESSION['token'] = randomString(60);
?>
Games