File manager - Edit - /home/webapp69.cm.in.th/u69319090001/Shop 001/login.php
Back
<?php /** * หน้าเข้าสู่ระบบสำหรับลูกค้า (Customer Login) * REDSHOP Pre-order System */ session_start(); require_once 'db.php'; // หากเข้าสู่ระบบอยู่แล้ว ให้เปลี่ยนเส้นทางไปหน้าแรก if (isset($_SESSION['user_id'])) { header("Location: index.php"); exit; } $error_msg = ''; $identifier = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $identifier = isset($_POST['identifier']) ? trim($_POST['identifier']) : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; if (empty($identifier) || empty($password)) { $error_msg = "กรุณากรอกข้อมูลให้ครบถ้วน"; } else { try { // ค้นหาผู้ใช้จาก เบอร์โทรศัพท์ หรือ อีเมล (ใช้ placeholder แยกกันเพื่อรองรับ PDO Native Prepare) $stmt = $pdo->prepare("SELECT * FROM users WHERE phone = :phone_ident OR email = :email_ident LIMIT 1"); $stmt->execute([ 'phone_ident' => $identifier, 'email_ident' => $identifier ]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password'])) { // บันทึก Session ข้อมูลผู้ใช้ $_SESSION['user_id'] = $user['id']; $_SESSION['user_name'] = $user['name']; $_SESSION['user_phone'] = $user['phone']; $_SESSION['user_email'] = $user['email']; $_SESSION['user_address'] = $user['address']; $_SESSION['success_msg'] = "ยินดีต้อนรับคุณ " . htmlspecialchars($user['name']) . " เข้าสู่ระบบสำเร็จ!"; // หากมี redirect target หรือกลับหน้าแรก $redirect = !empty($_SESSION['redirect_after_login']) ? $_SESSION['redirect_after_login'] : 'index.php'; unset($_SESSION['redirect_after_login']); header("Location: " . $redirect); exit; } else { $error_msg = "เบอร์โทรศัพท์/อีเมล หรือรหัสผ่านไม่ถูกต้อง"; } } catch (PDOException $e) { $error_msg = "เกิดข้อผิดพลาดของระบบ: " . $e->getMessage(); } } } ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>เข้าสู่ระบบสมาชิก - REDSHOP Pre-order</title> <!-- Google Fonts --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=Noto+Sans+Thai:wght@300;400;500;700&display=swap" rel="stylesheet"> <!-- Bootstrap 5 CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- FontAwesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> :root { --primary-red: #e61e2b; --hover-red: #c1101b; --light-red: #ffebeb; --dark-gray: #2d3748; --light-gray: #f7fafc; } body { font-family: 'Noto Sans Thai', 'Inter', sans-serif; background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; } .auth-card { background: #ffffff; border-radius: 24px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08); border: 1px solid rgba(230, 30, 43, 0.1); overflow: hidden; width: 100%; max-width: 440px; transition: transform 0.3s ease; } .auth-header { background: linear-gradient(135deg, var(--primary-red) 0%, #ff5252 100%); color: #fff; padding: 2.5rem 2rem 2rem; text-align: center; position: relative; } .auth-header::after { content: ''; position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); width: 30px; height: 30px; background: #fff; clip-path: polygon(50% 100%, 0 0, 100% 0); } .auth-header h3 { font-weight: 700; font-size: 1.6rem; margin-bottom: 0.25rem; } .auth-header p { font-size: 0.9rem; opacity: 0.9; margin-bottom: 0; } .auth-body { padding: 2.5rem 2rem 2rem; } .form-label { font-weight: 600; font-size: 0.9rem; color: var(--dark-gray); margin-bottom: 6px; } .input-group-text { background-color: #f8fafc; border-color: #e2e8f0; color: #718096; border-radius: 12px 0 0 12px; } .form-control { border-radius: 0 12px 12px 0; padding: 12px 14px; border-color: #e2e8f0; font-size: 0.95rem; } .form-control:focus { border-color: var(--primary-red); box-shadow: 0 0 0 3px rgba(230, 30, 43, 0.15); } .btn-red { background-color: var(--primary-red); color: #fff; font-weight: 600; border: none; padding: 12px; border-radius: 12px; width: 100%; transition: all 0.2s ease; box-shadow: 0 4px 12px rgba(230, 30, 43, 0.25); } .btn-red:hover { background-color: var(--hover-red); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(230, 30, 43, 0.35); } .auth-footer { text-align: center; padding: 0 2rem 2rem; font-size: 0.9rem; color: #718096; } .auth-footer a { color: var(--primary-red); text-decoration: none; font-weight: 600; } .auth-footer a:hover { text-decoration: underline; } .brand-link { display: inline-block; margin-bottom: 1rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; } </style> </head> <body> <div class="auth-card"> <div class="auth-header"> <a href="index.php" class="brand-link"> <i class="fa-solid fa-cart-shopping-fast me-2"></i>REDSHOP </a> <h3>เข้าสู่ระบบลูกค้า</h3> <p>ยินดีต้อนรับ! เข้าสู่ระบบเพื่อจัดการการจองของคุณ</p> </div> <div class="auth-body"> <?php if (isset($_SESSION['register_success'])): ?> <div class="alert alert-success alert-dismissible fade show py-2" style="font-size: 0.9rem;" role="alert"> <i class="fa-solid fa-circle-check me-2"></i><?php echo $_SESSION['register_success']; unset($_SESSION['register_success']); ?> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div> <?php endif; ?> <?php if (!empty($error_msg)): ?> <div class="alert alert-danger alert-dismissible fade show py-2" style="font-size: 0.9rem;" role="alert"> <i class="fa-solid fa-circle-exclamation me-2"></i><?php echo $error_msg; ?> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div> <?php endif; ?> <form action="login.php" method="POST"> <div class="mb-3"> <label for="identifier" class="form-label">เบอร์โทรศัพท์ หรือ อีเมล</label> <div class="input-group"> <span class="input-group-text"><i class="fa-solid fa-user"></i></span> <input type="text" class="form-control" id="identifier" name="identifier" value="<?php echo htmlspecialchars($identifier); ?>" placeholder="เช่น 0891234567 หรือ your@email.com" required autofocus> </div> </div> <div class="mb-4"> <div class="d-flex justify-content-between align-items-center"> <label for="password" class="form-label mb-0">รหัสผ่าน</label> </div> <div class="input-group mt-1"> <span class="input-group-text"><i class="fa-solid fa-lock"></i></span> <input type="password" class="form-control" id="password" name="password" placeholder="กรอกรหัสผ่านของคุณ" required> <button class="btn btn-outline-secondary" type="button" id="togglePass" style="border-radius: 0 12px 12px 0; border-color: #e2e8f0;"> <i class="fa-solid fa-eye" id="togglePassIcon"></i> </button> </div> </div> <button type="submit" class="btn btn-red mb-3"> <i class="fa-solid fa-right-to-bracket me-2"></i>เข้าสู่ระบบ </button> <div class="text-center"> <a href="index.php" class="text-muted small text-decoration-none"> <i class="fa-solid fa-arrow-left me-1"></i> กลับหน้าหลักร้านค้า </a> </div> </form> </div> <div class="auth-footer border-top pt-3"> ยังไม่มีบัญชีสมาชิก? <a href="register.php">สมัครสมาชิกใหม่</a> </div> </div> <!-- Bootstrap JS --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script> const togglePass = document.getElementById('togglePass'); const passwordInput = document.getElementById('password'); const togglePassIcon = document.getElementById('togglePassIcon'); togglePass.addEventListener('click', function () { const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password'; passwordInput.setAttribute('type', type); togglePassIcon.classList.toggle('fa-eye'); togglePassIcon.classList.toggle('fa-eye-slash'); }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings