prepare("INSERT INTO messages (sender_user_id, recipient_user_id, subject, body) VALUES (?, ?, ?, ?)"); $stmt->execute([$sender_user_id, $recipient_user_id, $subject, $body]); header("Location: " . $redirect_url . "?success=message_sent"); exit; } catch (PDOException $e) { // In a real app, log this error. header("Location: " . $redirect_url . "?error=db_error"); exit; }