| Server IP : 172.67.189.169 / Your IP : 216.73.216.59 Web Server : Apache/2 System : Linux cat167-197.static.lnwhostname.com 5.10.0-20-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64 User : paphayomho ( 1042) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/paphayomho/domains/paphayomhospital.go.th/public_html/procurement/ |
Upload File : |
<?php
include 'config.php'; // ตรวจสอบว่าในนี้มี session_start() และเชื่อมต่อตาราง adminpayom แล้ว
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// ใช้ trim() เพื่อตัดช่องว่างที่อาจติดมาจากการ copy
$user = trim($_POST['username']);
$pass = trim($_POST['password']);
// ดึงข้อมูลจากตาราง adminpayom
$stmt = $conn->prepare("SELECT id, password FROM adminpayom WHERE username = ?");
$stmt->bind_param("s", $user);
$stmt->execute();
$result = $stmt->get_result();
$userData = $result->fetch_assoc();
// ตรวจสอบรหัสผ่าน
if ($userData && password_verify($pass, $userData['password'])) {
$_SESSION['admin_login'] = $userData['id'];
header("Location: admin.php");
exit;
} else {
$error = "ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง!";
}
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { background-color: #f8f9fa; display: flex; align-items: center; height: 100vh; font-family: sans-serif; }
.login-card { width: 100%; max-width: 380px; padding: 2rem; margin: auto; background: #fff; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.error-box { background-color: #f8d7da; color: #721c24; padding: 15px; border-radius: 5px; margin-bottom: 20px; text-align: center; border: 1px solid #f5c6cb; }
</style>
</head>
<body>
<div class="login-card text-center">
<h2 class="mb-1">Admin Login</h2>
<p class="text-muted mb-4" style="font-size: 0.9rem;">(Table: adminpayom)</p>
<hr>
<?php if(isset($error)): ?>
<div class="error-box"><?= $error ?></div>
<?php endif; ?>
<form method="POST" class="text-start">
<div class="mb-3">
<label class="form-label">Username</label>
<input type="text" name="username" class="form-control bg-light" placeholder="admin" required>
</div>
<div class="mb-4">
<label class="form-label">Password</label>
<input type="password" name="password" class="form-control bg-light" placeholder="••••••••" required>
</div>
<button type="submit" class="btn btn-primary w-100 py-2">Login</button>
</form>
</div>
</body>
</html>