prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); if ($stmt->fetch()) { $errors[] = 'Username already taken. Please choose another one.'; } } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); } } // If no errors, create user if (empty($errors)) { $hashed_password = password_hash($password, PASSWORD_DEFAULT); try { $stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (?, ?)"); $stmt->execute([$username, $hashed_password]); $_SESSION['message'] = 'Registration successful! You can now log in.'; $_SESSION['message_type'] = 'success'; header("Location: login.php"); exit; } catch (PDOException $e) { $errors[] = "Database error on user creation: " . $e->getMessage(); } } } require_once __DIR__ . '/includes/header.php'; ?>

Create Your Account

Password must be at least 6 characters long.

Already have an account? Log in here.