+
+
+
+ diff --git a/index.php b/index.php index baa46a5..94f8a65 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,4 @@ +
@@ -35,13 +36,17 @@ @@ -92,31 +97,6 @@ - - - diff --git a/login.php b/login.php new file mode 100644 index 0000000..3885ff3 --- /dev/null +++ b/login.php @@ -0,0 +1,91 @@ +prepare("SELECT id, password, role_id FROM users WHERE username = :username"); + $stmt->bindParam(':username', $username); + $stmt->execute(); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $username; + $_SESSION['role_id'] = $user['role_id']; + header("Location: index.php"); + exit(); + } else { + $error_message = 'Invalid username or password.'; + } + } +} + +// Fetch header content +ob_start(); +include 'index.php'; +$page_content = ob_get_clean(); + +// Extract only the and