File manager - Edit - /home/webapp69.cm.in.th/u69319090030/030 shop/admin/register.php
Back
<?php require_once __DIR__ . '/../config/db.php'; require_once __DIR__ . '/../helpers/jwt_helper.php'; require_once __DIR__ . '/../helpers/auth.php'; // เด้งไปหน้าบอร์ดหากล็อกอินอยู่แล้ว if (get_current_user_data()) { header("Location: dashboard.php"); exit(); } $error = ''; $success = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = trim($_POST['username'] ?? ''); $email = trim($_POST['email'] ?? ''); $password = $_POST['password'] ?? ''; $invite_code = trim($_POST['invite_code'] ?? ''); if (empty($username) || empty($email) || empty($password) || empty($invite_code)) { $error = 'กรุณากรอกข้อมูลให้ครบถ้วนทุกช่อง'; } elseif ($invite_code !== INVITE_CODE) { $error = 'รหัสเชิญชวน (Invite Code) ไม่ถูกต้อง ปฏิเสธการสมัคร'; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error = 'รูปแบบอีเมลไม่ถูกต้อง'; } else { try { // ตรวจสอบว่าชื่อผู้ใช้หรืออีเมลมีอยู่แล้วหรือไม่ $stmt = $pdo->prepare("SELECT id FROM users WHERE username = ? OR email = ?"); $stmt->execute([$username, $email]); if ($stmt->fetch()) { $error = 'ชื่อผู้ใช้งานหรืออีเมลนี้ถูกใช้ลงทะเบียนไปแล้ว'; } else { // บันทึกข้อมูลและตั้งสถานะเป็น pending $hashed_password = password_hash($password, PASSWORD_BCRYPT); $stmt = $pdo->prepare("INSERT INTO users (username, email, password, role, status) VALUES (?, ?, ?, 'admin', 'pending')"); $stmt->execute([$username, $email, $hashed_password]); $success = 'ลงทะเบียนแอดมินใหม่เรียบร้อย! โปรดรอให้ Super Admin กดอนุมัติเปิดสิทธิ์ใช้งานก่อนเข้าใช้งานระบบ'; } } catch (PDOException $e) { $error = 'ระบบฐานข้อมูลขัดข้อง: ' . $e->getMessage(); } } } ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>CyberShop // ลงทะเบียนแอดมิน</title> <link rel="stylesheet" href="../assets/css/style.css"> </head> <body style="display: flex; min-height: 100vh; align-items: center; justify-content: center; background: radial-gradient(circle at center, #1a080d 0%, #0d0d0d 100%);"> <div class="cyber-card" style="width: 100%; max-width: 450px;"> <div style="text-align: center; margin-bottom: 2rem;"> <a href="#" class="navbar-brand" style="justify-content: center; font-size: 2rem;"> CYBER<span class="brand-red">PORTAL</span> </a> <p style="font-size: 0.9rem; letter-spacing: 2px; text-transform: uppercase; margin-top: 0.5rem; color: var(--text-gray);"> ลงทะเบียนขอสิทธิ์ผู้ดูแลระบบใหม่ </p> </div> <?php if ($error): ?> <div class="cyber-alert cyber-alert-error"> <strong>[เกิดข้อผิดพลาด]</strong> <?php echo htmlspecialchars($error); ?> </div> <?php endif; ?> <?php if ($success): ?> <div class="cyber-alert cyber-alert-success"> <strong>[สำเร็จ]</strong> <?php echo htmlspecialchars($success); ?> </div> <?php endif; ?> <form action="" method="POST"> <div class="cyber-input-group"> <label class="cyber-label" for="username">ชื่อผู้ใช้งานแอดมิน (Username)</label> <input class="cyber-input" type="text" id="username" name="username" placeholder="ตั้งชื่อบัญชีแอดมิน" required value="<?php echo htmlspecialchars($username ?? ''); ?>"> </div> <div class="cyber-input-group"> <label class="cyber-label" for="email">อีเมลยืนยันความปลอดภัย (Email)</label> <input class="cyber-input" type="email" id="email" name="email" placeholder="admin@domain.com" required value="<?php echo htmlspecialchars($email ?? ''); ?>"> </div> <div class="cyber-input-group"> <label class="cyber-label" for="password">รหัสผ่านสำหรับถอดรหัสเข้าสู่ระบบ (Password)</label> <input class="cyber-input" type="password" id="password" name="password" placeholder="••••••••" required> </div> <div class="cyber-input-group"> <label class="cyber-label" for="invite_code" style="color: var(--neon-red);">รหัสเชิญชวนการเข้าร่วม (Invite Code)</label> <input class="cyber-input" type="text" id="invite_code" name="invite_code" placeholder="ป้อนรหัสเชิญชวนแอดมิน" required style="border-color: rgba(255, 0, 85, 0.4);"> </div> <button type="submit" class="btn-cyber" style="width: 100%; margin-top: 1rem;"> เริ่มการลงทะเบียนแอดมิน </button> </form> <div style="text-align: center; margin-top: 1.5rem; font-size: 0.9rem;"> มีสิทธิ์ผ่านทางแล้ว? <a href="login.php" style="color: var(--neon-red); text-decoration: none; font-weight: bold;">เข้าสู่ระบบตรงนี้</a> </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.28 |
proxy
|
phpinfo
|
Settings