prepare($sql); $stmt->execute([$email]); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user && password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['user_name'] = $user['name']; $_SESSION['user_role'] = $user['role']; if ($user['role'] === 'admin') { header("location: admin_dashboard.php"); // Create this page next } else { header("location: user_dashboard.php"); // Create this page next } exit; } else { $error = "The email or password you entered is incorrect."; } } catch (PDOException $e) { $error = "Database error: " . $e->getMessage(); } } } ?> Login - READY BUDDY

Login to Your Account