prepare("SELECT * FROM users WHERE email = ?"); $stmt->execute([$email]); $existing_user = $stmt->fetch(); if ($existing_user) { $errors[] = 'A user with this email already exists.'; } else { $hashed_password = password_hash($password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (full_name, email, phone, password) VALUES (?, ?, ?, ?)"); $stmt->execute([$full_name, $email, $phone, $hashed_password]); header("Location: login.php?registration=success"); exit; } } catch (PDOException $e) { // In a real app, you would log this error, not show it to the user. $errors[] = "Database error. Please try again later."; } } } $pageTitle = 'Sign Up'; require_once __DIR__ . '/shared/header.php'; ?>

Create an Account