|
2 | 2 | session_start(); |
3 | 3 | include 'db_connection.php'; |
4 | 4 |
|
| 5 | +$error = ""; |
| 6 | + |
5 | 7 | if (isset($_POST['login'])) { |
| 8 | + |
6 | 9 | $gmail = mysqli_real_escape_string($conn, $_POST['gmail']); |
7 | | - $password = md5($_POST['password']); // later: use password_hash() |
| 10 | + $password = md5($_POST['password']); |
8 | 11 |
|
9 | 12 | $sql = "SELECT * FROM userdata WHERE gmail='$gmail' AND password='$password'"; |
10 | 13 | $result = mysqli_query($conn, $sql); |
11 | 14 |
|
12 | 15 | if (mysqli_num_rows($result) > 0) { |
13 | 16 | $_SESSION['gmail'] = $gmail; |
14 | | - header("Location: ../dashboard/dash.php"); // corrected path |
| 17 | + header("Location: ../Saklaw/home.php"); |
15 | 18 | exit(); |
16 | 19 | } else { |
17 | 20 | $error = "Invalid gmail or password!"; |
18 | 21 | } |
19 | 22 | } |
20 | 23 | ?> |
21 | | - |
22 | 24 | <!DOCTYPE html> |
23 | 25 | <html lang="en"> |
24 | 26 | <head> |
25 | 27 | <meta charset="UTF-8"> |
26 | 28 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
27 | 29 | <title>Login</title> |
28 | 30 | <link rel="stylesheet" href="../../../Saklaw/assets/css/auth.css"> |
| 31 | + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css"> |
| 32 | + |
| 33 | + <style> |
| 34 | + |
| 35 | +.password-wrapper { |
| 36 | + position: relative; |
| 37 | + width: 100%; |
| 38 | +} |
| 39 | + |
| 40 | +.password-wrapper input { |
| 41 | + width: 100%; |
| 42 | + padding-right: 40px; |
| 43 | + box-sizing: border-box; |
| 44 | +} |
| 45 | + |
| 46 | +.password-wrapper #togglePassword { |
| 47 | + position: absolute; |
| 48 | + right: 10px; |
| 49 | + top: 50%; |
| 50 | + transform: translateY(-50%); |
| 51 | + cursor: pointer; |
| 52 | + color: #666; |
| 53 | + font-size: 1.2rem; |
| 54 | +} |
| 55 | + </style> |
29 | 56 | </head> |
30 | 57 | <body> |
31 | 58 |
|
32 | 59 | <div class="login-wrapper"> |
33 | 60 | <div class="login-box"> |
34 | 61 | <h2>Login</h2> |
35 | | - <form method="POST" action="login"> |
| 62 | + |
| 63 | + <form method="POST" action=""> |
36 | 64 | <input type="email" name="gmail" placeholder="Gmail" required> |
37 | | - <input type="password" name="password" placeholder="Password" required> |
38 | | - <?php if (!empty($error)) echo "<p class='error'>$error</p>"; //pang display ng error?> |
| 65 | + |
| 66 | + <div class="password-wrapper"> |
| 67 | + <input type="password" id="password" name="password" placeholder="Password" required> |
| 68 | + <i class="bi bi-eye-slash" id="togglePassword"></i> |
| 69 | + </div> |
| 70 | + |
| 71 | + <?php if (!empty($error)) echo "<p class='error'>$error</p>"; ?> |
| 72 | + |
39 | 73 | <button type="submit" name="login">Login</button> |
40 | 74 | </form> |
41 | | - <p class="signup-link">Don't have an account? <a href="../../../Saklaw/pages/auth/signUp.php">Sign up</a></p> |
| 75 | + |
| 76 | + <p class="signup-link"> |
| 77 | + Don't have an account? |
| 78 | + <a href="../../../Saklaw/pages/auth/signUp.php">Sign up</a> |
| 79 | + </p> |
42 | 80 | </div> |
43 | 81 | </div> |
44 | 82 |
|
| 83 | +<script> |
| 84 | +const togglePassword = document.querySelector("#togglePassword"); |
| 85 | +const password = document.querySelector("#password"); |
| 86 | + |
| 87 | +togglePassword.addEventListener("click", function () { |
| 88 | + const type = password.getAttribute("type") === "password" ? "text" : "password"; |
| 89 | + password.setAttribute("type", type); |
| 90 | + |
| 91 | + this.classList.toggle("bi-eye"); |
| 92 | + this.classList.toggle("bi-eye-slash"); |
| 93 | +}); |
| 94 | +</script> |
| 95 | + |
45 | 96 | </body> |
46 | 97 | </html> |
0 commit comments