File manager - Edit - /home/webapp69.cm.in.th/u69319090044/shop/login.php
Back
<?php // login.php - Login authentication view page require_once 'includes/helper.php'; require_once 'classes/User.php'; start_secure_session(); // Handle Logout if (isset($_GET['action']) && $_GET['action'] === 'logout') { $_SESSION = []; session_destroy(); header("Location: login.php"); exit(); } // Redirect if already logged in if (isset($_SESSION['user_id'])) { header("Location: index.php"); exit(); } $error = ''; $csrfToken = generate_csrf_token(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = trim($_POST['username'] ?? ''); $password = trim($_POST['password'] ?? ''); $token = $_POST['csrf_token'] ?? ''; // Validate CSRF if (!validate_csrf_token($token)) { $error = "ระบบความปลอดภัย: CSRF Token ไม่ถูกต้อง"; } else if (empty($username) || empty($password)) { $error = "กรุณากรอกชื่อผู้ใช้และรหัสผ่าน"; } else { $userObj = new User(); $user = $userObj->authenticate($username, $password); if ($user) { $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; $_SESSION['first_name'] = $user['first_name']; $_SESSION['role'] = $user['role']; header("Location: index.php"); exit(); } else { $error = "ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง"; } } } require_once 'includes/header.php'; ?> <div class="max-w-md mx-auto my-4 sm:my-10"> <div class="glass p-6 sm:p-8 rounded-2xl sm:rounded-3xl shadow-2xl relative overflow-hidden"> <!-- Decoration light glow --> <div class="absolute -top-12 -right-12 w-32 h-32 bg-violet-600/20 rounded-full blur-2xl"></div> <h2 class="text-3xl font-extrabold text-white mb-2 text-center tracking-tight">เข้าสู่ระบบ</h2> <p class="text-slate-400 text-sm text-center mb-8">เพื่อเริ่มต้นการสั่งซื้อสินค้าของคุณ</p> <?php if ($error): ?> <div class="bg-red-950/60 border border-red-800 text-red-300 p-4 rounded-xl text-sm mb-6 animate-pulse"> ⚠️ <?= escape($error) ?> </div> <?php endif; ?> <form action="login.php" method="POST" class="space-y-6"> <input type="hidden" name="csrf_token" value="<?= escape($csrfToken) ?>"> <div> <label for="username" class="block text-xs font-semibold uppercase tracking-wider text-slate-400 mb-2">ชื่อผู้ใช้งาน (Username)</label> <input type="text" name="username" id="username" required class="w-full px-4 py-3 bg-slate-900 border border-slate-800 focus:border-violet-500 rounded-xl focus:ring-1 focus:ring-violet-500 outline-none text-slate-100 placeholder-slate-600 transition-all" placeholder="ป้อนชื่อผู้ใช้งาน"> </div> <div> <label for="password" class="block text-xs font-semibold uppercase tracking-wider text-slate-400 mb-2">รหัสผ่าน (Password)</label> <input type="password" name="password" id="password" required class="w-full px-4 py-3 bg-slate-900 border border-slate-800 focus:border-violet-500 rounded-xl focus:ring-1 focus:ring-violet-500 outline-none text-slate-100 placeholder-slate-600 transition-all" placeholder="••••••••"> </div> <button type="submit" class="w-full py-3.5 bg-gradient-to-r from-violet-600 to-indigo-600 hover:from-violet-500 hover:to-indigo-500 text-white font-semibold rounded-xl shadow-lg shadow-violet-600/35 transition-all duration-200"> เข้าสู่ระบบ 🚀 </button> </form> <div class="mt-6 text-center text-xs text-slate-400"> ยังไม่มีบัญชีผู้ใช้งาน? <a href="register.php" class="text-violet-400 font-semibold hover:text-violet-300">สมัครสมาชิกได้ที่นี่</a> </div> </div> </div> <?php require_once 'includes/footer.php'; ?>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings