prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { die('An account with this email already exists. Log in here.'); } try { // Create the user with the 'customer' role $stmt_user = $pdo->prepare( "INSERT INTO users (name, email, password, role) VALUES (?, ?, ?, 'customer')" ); $stmt_user->execute([$name, $email, $password]); // Redirect to the login page with a success message header("Location: login.php?signup=success"); exit(); } catch (PDOException $e) { // In a real app, you would log this error die("Error creating account: " . $e->getMessage()); }