How can one optimize the PHP code for a contact form to improve performance and user experience?

Issue: One way to optimize the PHP code for a contact form is to minimize the number of database queries by combining multiple queries into a single query. This can improve performance and reduce the load on the server, resulting in a better user experience.

// Combine multiple queries into a single query
$stmt = $pdo->prepare("INSERT INTO contacts (name, email, message) VALUES (:name, :email, :message)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':message', $message);
$stmt->execute();