Spaces:
Sleeping
Sleeping
Kush-Singh-26
synced backend and frontend, added more menu items, ui and admin page improvements
56fb0d1 Download api/login.php from Kush26/kiit-kaffe: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/Kush26/kiit-kaffe/resolve/main/api/login.php
- Command line
-
hf download hf://spaces/Kush26/kiit-kaffe/api/login.php
-
curl -L -o login.php https://huggingface.co/spaces/Kush26/kiit-kaffe/resolve/main/api/login.php
1.04 kB
| header("Content-Type: application/json"); | |
| include "db.php"; | |
| $data = json_decode(file_get_contents("php://input"), true); | |
| if (!isset($data["email"], $data["password"])) { | |
| echo json_encode(["status" => "error", "message" => "Missing fields"]); | |
| exit; | |
| } | |
| $email = trim($data["email"]); | |
| $password = $data["password"]; | |
| $stmt = $conn->prepare("SELECT id, name, email, password, phone, role FROM users WHERE email = ?"); | |
| $stmt->execute([$email]); | |
| $user = $stmt->fetch(); | |
| if ($user) { | |
| if ($password === $user['password']) { | |
| echo json_encode([ | |
| "status" => "success", | |
| "user" => [ | |
| "id" => $user['id'], | |
| "name" => $user['name'], | |
| "email" => $user['email'], | |
| "phone" => $user['phone'], | |
| "role" => $user['role'] | |
| ] | |
| ]); | |
| } else { | |
| echo json_encode(["status" => "error", "message" => "Invalid password"]); | |
| } | |
| } else { | |
| echo json_encode(["status" => "error", "message" => "User not found"]); | |
| } | |