Download change_password.php from Presidor1/STC_APP: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/spaces/Presidor1/STC_APP/resolve/main/change_password.php
- Command line
-
hf download hf://spaces/Presidor1/STC_APP/change_password.php
-
curl -L -o change_password.php https://huggingface.co/spaces/Presidor1/STC_APP/resolve/main/change_password.php
2.34 kB
| session_start(); | |
| if (!isset($_SESSION['admin'])) { | |
| header("Location: admin_login.php"); | |
| exit(); | |
| } | |
| $conn = new mysqli("localhost", "root", "", "stc_db"); | |
| if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); | |
| $msg = ""; | |
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
| $old = sha1($_POST['old_password']); | |
| $new = sha1($_POST['new_password']); | |
| $confirm = sha1($_POST['confirm_password']); | |
| $username = $_SESSION['admin']; | |
| $res = $conn->query("SELECT * FROM admin_users WHERE username='$username' AND password='$old'"); | |
| if ($res->num_rows == 1) { | |
| if ($new === $confirm) { | |
| $conn->query("UPDATE admin_users SET password='$new' WHERE username='$username'"); | |
| $msg = "Password updated successfully!"; | |
| } else { | |
| $msg = "New passwords do not match."; | |
| } | |
| } else { | |
| $msg = "Old password is incorrect."; | |
| } | |
| } | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Change Password</title> | |
| <style> | |
| body { font-family: Arial; padding: 20px; background: #f0f0f0; } | |
| .container { | |
| max-width: 400px; margin: auto; background: white; | |
| padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); | |
| } | |
| h2 { color: #004e56; text-align: center; } | |
| input[type="password"] { | |
| width: 100%; padding: 10px; margin: 10px 0; | |
| border: 1px solid #ccc; border-radius: 6px; | |
| } | |
| button { | |
| width: 100%; padding: 10px; | |
| background: #004e56; color: white; border: none; border-radius: 6px; | |
| } | |
| .message { color: red; text-align: center; } | |
| .success { color: green; } | |
| a { display: block; text-align: center; margin-top: 15px; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h2>Change Admin Password</h2> | |
| <?php if ($msg): ?> | |
| <div class="message <?= strpos($msg, 'success') !== false ? 'success' : '' ?>"><?= $msg ?></div> | |
| <?php endif; ?> | |
| <form method="post"> | |
| <input type="password" name="old_password" placeholder="Old Password" required /> | |
| <input type="password" name="new_password" placeholder="New Password" required /> | |
| <input type="password" name="confirm_password" placeholder="Confirm New Password" required /> | |
| <button type="submit">Change Password</button> | |
| </form> | |
| <a href="dashboard.php">← Back to Dashboard</a> | |
| </div> | |
| </body> | |
| </html> |