I have a checkbox that confirms if the sender wants the copy of the form to his/her email. Now, how can I have get it to work with PHP?
I have the following HTML form cod
First, check if the "sendcopy" checkbox is checked:
$sendCopy = isset($_POST['sendcopy']);
You don't have to check its value. The frontend simply won't send anything if the checkbox is not checked, so if it exists in the $_POST array, that means the user has checked it.
Next, just send the exact same mail to the sender's email address:
if ($sendCopy) {
$sentToSender = mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head);
}
You can add this code just before redirecting your user to the success page.
The missing parentheses have now been added to the code above, so it works well.