This code works in the older version of mysql that is below 5.7 but it does not work in the current one. It always selects the last else statement. Is there anything wrong with the code please.
if($action == 'login')
{
$login_id = strip_tags($_POST['login-id']);
$security_code = strip_tags($_POST['security-code']);
$check_login = $db->prepare("SELECT COUNT(*) AS rows FROM login WHERE login_id = ? AND security_code = ?");
$check_login->execute(array($login_id, $security_code));
$data = $check_login->fetch();
$rows = $data['rows'];
if($rows > 0 )
{
$query = $db->prepare('SELECT * FROM login WHERE login_id = ? AND security_code = ?');
$query->execute(array($login_id, $security_code));
$data = $query->fetch();
$login_id = $data['login_id'];
$_SESSION['login_id'] = $login_id;
if($login_id == 'admin' or $login_id == 'webmaster')
{
$_SESSION['admin'] = true;
header("Location:../control-panel.php");
exit;
}
else
}
else
{
header('Location:../index.php?m=invalid');
}