prepare($sql); $stmt->execute([$email]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['user_name'] = $user['name']; header("Location: index.php"); exit; } else { die('Invalid email or password.'); } } catch (PDOException $e) { die("Could not connect to the database $dbname :" . $e->getMessage()); } } ?>