How can PHP be used to send emails with user input and links for confirmation or rejection in a web application?

To send emails with user input and links for confirmation or rejection in a web application using PHP, you can use the PHP `mail()` function to send the email with the user input and links embedded in the email body. You can generate unique confirmation or rejection links for each user and include them in the email content. When the user clicks on the link, you can handle the confirmation or rejection logic in your PHP script.

<?php
$to = "recipient@example.com";
$subject = "Confirmation Email";
$user_input = $_POST['user_input']; // Assuming user input is submitted via a form

$confirmation_link = "http://example.com/confirm.php?user_input=" . $user_input;
$rejection_link = "http://example.com/reject.php?user_input=" . $user_input;

$message = "Please confirm or reject the user input: $user_input. <br><br>";
$message .= "Click <a href='$confirmation_link'>here</a> to confirm.<br>";
$message .= "Click <a href='$rejection_link'>here</a> to reject.<br>";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

mail($to, $subject, $message, $headers);
?>