Spaces:
Configuration error
Configuration error
Download login.php from brucelloyd1/lost-found-tracker-pro: direct link, hf CLI and curl.
- Browser
- Download file 4.86 kB
-
https://huggingface.co/spaces/brucelloyd1/lost-found-tracker-pro/resolve/main/login.php
- Command line
-
hf download hf://spaces/brucelloyd1/lost-found-tracker-pro/login.php
-
curl -L -o login.php https://huggingface.co/spaces/brucelloyd1/lost-found-tracker-pro/resolve/main/login.php
4.86 kB
| ```php | |
| include 'config/database.php'; | |
| include 'includes/auth.php'; | |
| if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
| $email = $_POST['email'] ?? ''; | |
| $password = $_POST['password'] ?? ''; | |
| $is_admin = isset($_POST['is_admin']); | |
| $db = new Database(); | |
| $connection = $db->getConnection(); | |
| if ($is_admin) { | |
| // Admin login | |
| $query = "SELECT * FROM admins WHERE username = :username"; | |
| $stmt = $connection->prepare($query); | |
| $stmt->bindParam(':username', $email); | |
| $stmt->execute(); | |
| if ($stmt->rowCount() == 1) { | |
| $admin = $stmt->fetch(PDO::FETCH_ASSOC); | |
| // For demo purposes, using simple password check. In production, use password_verify() | |
| if ($password === 'admin123' || password_verify($password, $admin['passwordHash'])) { | |
| $_SESSION['admin_id'] = $admin['adminId']; | |
| $_SESSION['admin_name'] = $admin['name']; | |
| header("Location: admin.php"); | |
| exit(); | |
| } | |
| } | |
| $error = "Invalid admin credentials"; | |
| } else { | |
| // User login | |
| $query = "SELECT * FROM users WHERE email = :email"; | |
| $stmt = $connection->prepare($query); | |
| $stmt->bindParam(':email', $email); | |
| $stmt->execute(); | |
| if ($stmt->rowCount() == 1) { | |
| $user = $stmt->fetch(PDO::FETCH_ASSOC); | |
| // For demo purposes, using simple password check. In production, use password_verify() | |
| if ($password === 'user123' || password_verify($password, $user['passwordHash'])) { | |
| $_SESSION['user_id'] = $user['userId']; | |
| $_SESSION['user_name'] = $user['name']; | |
| $_SESSION['role'] = $user['role']; | |
| $_SESSION['email'] = $user['email']; | |
| header("Location: dashboard.php"); | |
| exit(); | |
| } | |
| } | |
| $error = "Invalid email or password"; | |
| } | |
| } | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Login - Lost & Found</title> | |
| <link rel="stylesheet" href="style.css"> | |
| </head> | |
| <body> | |
| <header> | |
| <div class="container"> | |
| <nav> | |
| <div class="logo">Lost & Found Pro</div> | |
| <ul class="nav-links"> | |
| <li><a href="home.php">Home</a></li> | |
| <li><a href="items.php">Browse Items</a></li> | |
| <li><a href="login.php">Login</a></li> | |
| <li><a href="register.php">Register</a></li> | |
| </ul> | |
| </nav> | |
| </div> | |
| </header> | |
| <main class="container"> | |
| <div style="max-width: 400px; margin: 4rem auto;"> | |
| <div class="card"> | |
| <div class="card-header"> | |
| <h2 class="text-center">Login</h2> | |
| </div> | |
| <?php if (isset($error)): ?> | |
| <div style="background: #FEE2E2; color: #DC2626; padding: 1rem; border-radius: 5px; margin-bottom: 1rem;"> | |
| <?php echo $error; ?> | |
| </div> | |
| <?php endif; ?> | |
| <form method="POST"> | |
| <div class="form-group"> | |
| <label for="email">Email/Username</label> | |
| <input type="text" id="email" name="email" class="form-control" required> | |
| </div> | |
| <div class="form-group"> | |
| <label for="password">Password</label> | |
| <input type="password" id="password" name="password" class="form-control" required> | |
| </div> | |
| <div class="form-group"> | |
| <label> | |
| <input type="checkbox" name="is_admin"> Login as Administrator | |
| </label> | |
| </div> | |
| <button type="submit" class="btn btn-primary w-full">Login</button> | |
| </form> | |
| <p class="text-center mt-2"> | |
| Don't have an account? <a href="register.php">Register here</a> | |
| </p> | |
| <div class="mt-2" style="font-size: 0.9rem; color: #6B7280;"> | |
| <p><strong>Demo Credentials:</strong></p> | |
| <p>User (Finder/Owner): alice.finder@example.com / user123</p> | |
| <p>Admin: admin / admin123</p> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <footer> | |
| <div class="container"> | |
| <div class="footer-content"> | |
| <div class="logo">Lost & Found Pro</div> | |
| <p>© 2024 Lost & Found Management System. All rights reserved.</p> | |
| </div> | |
| </div> | |
| </footer> | |
| </body> | |
| </html> | |
| ``` |