diff --git a/admin_dashboard.php b/admin_dashboard.php new file mode 100644 index 0000000..2800759 --- /dev/null +++ b/admin_dashboard.php @@ -0,0 +1,30 @@ + + + + + + + + Admin Dashboard + + + +
+
+

Welcome, Admin!

+

This is your admin dashboard. You have successfully logged in.

+
+

You can now manage your application from here.

+ Logout +
+
+ + diff --git a/assets/pasted-20251110-043249-a340b856.png b/assets/pasted-20251110-043249-a340b856.png new file mode 100644 index 0000000..9a59628 Binary files /dev/null and b/assets/pasted-20251110-043249-a340b856.png differ diff --git a/login.php b/login.php new file mode 100644 index 0000000..b003120 --- /dev/null +++ b/login.php @@ -0,0 +1,91 @@ +prepare('SELECT * FROM public.admin_users WHERE email = ?'); + $stmt->execute([$email]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + // IMPORTANT: PHP's password_verify function is the correct way to check a bcrypt hash. + if ($user && password_verify($password, $user['password'])) { + // Password is correct, so start a new session + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_email'] = $user['email']; + $_SESSION['user_fullname'] = $user['full_name']; + + // Redirect to a protected admin page + header("Location: admin_dashboard.php"); + exit; + } else { + // Invalid credentials + $error_message = 'Invalid email or password.'; + } + } catch (PDOException $e) { + // In a real app, you would log this error, not show it to the user. + $error_message = 'Database error. Please try again later.'; + // error_log($e->getMessage()); + } + } +} +?> + + + + + + Admin Login + + + + +
+
+

Admin Login

+ + + + + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..06d0155 --- /dev/null +++ b/logout.php @@ -0,0 +1,13 @@ + \ No newline at end of file