prepare("SELECT id FROM users WHERE username = ? OR email = ?"); $stmt->execute([$username, $email]); if ($stmt->fetch()) { $errors[] = 'Username or email already taken'; } } // Insert user if no errors if (empty($errors)) { $password_hash = password_hash($password, PASSWORD_DEFAULT); $stmt = db()->prepare("INSERT INTO users (username, email, password_hash) VALUES (?, ?, ?)"); if ($stmt->execute([$username, $email, $password_hash])) { // Redirect to login page header("Location: login.php?registration=success"); exit(); } else { $errors[] = 'Something went wrong. Please try again.'; } } } ?>

Create an Account

Already have an account? Login here.