File manager - Edit - /home/webapp69.cm.in.th/u69319090042/Shop/register.php
Back
<?php require_once 'config.php'; if (isLoggedIn()) { header('Location: index.php'); exit; } $error = ''; $success = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = trim($_POST['username']); $password = $_POST['password']; $full_name = trim($_POST['full_name']); $email = trim($_POST['email']); $address = trim($_POST['address']); if (empty($username) || empty($password) || empty($full_name) || empty($email)) { $error = "Please fill in all required fields."; } else { // Check if username already exists $stmt = $pdo->prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); if ($stmt->fetch()) { $error = "Username is already taken."; } else { // Hash password and insert $hashed_password = password_hash($password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (username, password, full_name, email, address) VALUES (?, ?, ?, ?, ?)"); try { $stmt->execute([$username, $hashed_password, $full_name, $email, $address]); $success = "Registration successful! You can now log in."; } catch (PDOException $e) { $error = "Registration failed. Please try again."; } } } } ?> <?php include 'header.php'; ?> <div class="container"> <div class="auth-card"> <h2>Join Aora Closet</h2> <?php if (!empty($error)): ?> <div class="alert alert-danger"><?php echo $error; ?></div> <?php endif; ?> <?php if (!empty($success)): ?> <div class="alert alert-success"><?php echo $success; ?></div> <?php endif; ?> <form action="register.php" method="POST"> <div class="form-group"> <label for="full_name">Full Name *</label> <input type="text" id="full_name" name="full_name" class="form-control" placeholder="Jane Doe" required> </div> <div class="form-group"> <label for="email">Email Address *</label> <input type="email" id="email" name="email" class="form-control" placeholder="jane@example.com" required> </div> <div class="form-group"> <label for="username">Username *</label> <input type="text" id="username" name="username" class="form-control" placeholder="janedoe123" required> </div> <div class="form-group"> <label for="password">Password *</label> <input type="password" id="password" name="password" class="form-control" placeholder="Minimum 6 characters" required> </div> <div class="form-group"> <label for="address">Shipping Address</label> <textarea id="address" name="address" class="form-control" rows="3" placeholder="Enter your default shipping address..."></textarea> </div> <button type="submit" class="btn btn-primary" style="width: 100%; margin-top: 10px;">Create Account</button> </form> <p style="text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted);"> Already have an account? <a href="login.php" style="color: var(--primary-hover); font-weight: 600;">Log In</a> </p> </div> </div> <?php include 'footer.php'; ?>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings