🐘
signup.php
Back
📝 Php ⚡ Executable Ctrl+S: Save • Ctrl+R: Run • Ctrl+F: Find
<?php require_once 'db_config.php'; $pdo = getDB(); $message = ''; // Handle form submission if ($_POST) { $username = trim($_POST['username']); $email = trim($_POST['email']); $password = $_POST['password']; $confirm_password = $_POST['confirm_password']; // Basic validation if (empty($username) || empty($email) || empty($password)) { $message = '<div class="error">All fields are required!</div>'; } elseif ($password !== $confirm_password) { $message = '<div class="error">Passwords do not match!</div>'; } else { try { // Check if username or email already exists $check = $pdo->prepare("SELECT id FROM users WHERE username = ? OR email = ?"); $check->execute([$username, $email]); if ($check->rowCount() > 0) { $message = '<div class="error">Username or email already exists!</div>'; } else { // Insert new user (using plain text password for now) $insert = $pdo->prepare("INSERT INTO users (username, email, password_hash, plan_type, status) VALUES (?, ?, ?, 'free', 'active')"); $insert->execute([$username, $email, $password]); $message = '<div class="success">Account created successfully! <a href="login.php">Login here</a></div>'; } } catch(PDOException $e) { $message = '<div class="error">Error creating account: ' . $e->getMessage() . '</div>'; } } } ?> <!DOCTYPE html> <html> <head> <title>Sign Up - Game Development Platform</title> <style> body { font-family: Arial; margin: 0; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; } .container { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 400px; } h1 { text-align: center; color: #333; margin-bottom: 30px; } .form-group { margin-bottom: 20px; } label { display: block; margin-bottom: 5px; color: #555; font-weight: bold; } input[type="text"], input[type="email"], input[type="password"] { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 5px; font-size: 16px; box-sizing: border-box; } input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus { border-color: #667eea; outline: none; } .btn { width: 100%; padding: 12px; background: #667eea; color: white; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; } .btn:hover { background: #5a67d8; } .error { background: #fee; color: #c33; padding: 10px; border-radius: 5px; margin-bottom: 20px; border: 1px solid #fcc; } .success { background: #efe; color: #393; padding: 10px; border-radius: 5px; margin-bottom: 20px; border: 1px solid #cfc; } .links { text-align: center; margin-top: 20px; } .links a { color: #667eea; text-decoration: none; } .links a:hover { text-decoration: underline; } </style> </head> <body> <div class="container"> <h1>🎮 Join the Platform</h1> <?php echo $message; ?> <form method="POST"> <div class="form-group"> <label for="username">Username:</label> <input type="text" id="username" name="username" value="<?php echo isset($_POST['username']) ? htmlspecialchars($_POST['username']) : ''; ?>" required> </div> <div class="form-group"> <label for="email">Email:</label> <input type="email" id="email" name="email" value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : ''; ?>" required> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" id="password" name="password" required> </div> <div class="form-group"> <label for="confirm_password">Confirm Password:</label> <input type="password" id="confirm_password" name="confirm_password" required> </div> <button type="submit" class="btn">Create Account</button> </form> <div class="links"> <a href="login.php">Already have an account? Login</a> | <a href="index.php">Back to Home</a> </div> </div> </body> </html>