I have a checkbox, what confirms if sender want the copy of the form to his email.
Now I have to get it working with PHP, so how can I get it working with PHP ?
I have following HTML form code, "sendcopy checkbox" shows bottom of this code:
<form id="contact-form" action="send_form.php" method="post">
<input type="hidden" name="recipient" value="myemail@domain.net">
<input type="hidden" name="inhtml" value="yes">
<div class="contact-row">
<div style="float: left; width: 34%;">
<input class="contact-input" style="width: 300px;" name="name" placeholder="Name*" required><br>
</div>
<div style="float: left; width: 33%;">
<input class="contact-input" style="width: 290px;" name="email" placeholder="Email" type="email"><br>
</div>
<div style="float: right; width: 33%;">
<input class="contact-input" style="width: 305px;" name="subject" placeholder="Subject*" required><br>
</div>
</div>
<br>
<br>
<br>
<div class="contact-row">
<textarea cols="173" rows="10" name="message" placeholder="Message*" required></textarea><br>
</div>
<br>
<label>
<input type="checkbox" name="sendcopy" value="Yes" checked/>Send copy to your mail
</label>
<br>
<div class="confirm">
<label>
<input type="checkbox" name="confirm" required>
Confirm that you are people.
</label>
</div>
<br>
<br>
<div class="contact-row">
<div class="contact-row">
<center>
<input id="contact-submit" type="image" src="submit.png" alt="Send" />
</center>
</div>
</div>
</form>
And my PHP code:
<?php
$recipient = $_POST["recipient"];
$subject = $_POST["subject"];
$inhtml = $_POST["inhtml"];
$email = $_POST["email"];
$name = $_POST["name"];
$message = $_POST["message"];
$charset = 'utf-8';
$head =
"From: $email \r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=$charset\r\n" .
"Content-Transfer-Encoding: 8bit";
$body = '';
if ($inhtml == 'yes'){
$body = '<html><body style="font-family: Arial; color: #727272;">';
$body = $body . '<h3 style="font-size: 16px;">Name: ' . $name . '</h3>';
$body = $body . '<h4 style="font-size: 14px;">Subject: ' . $subject . ' (' . $email . ') </h4>';
$body = $body . '<p style="font-size: 13px;">' . $message . '</p>';
$body = $body . '</body></html>';
}
else {
$body = $body . 'Name: ' . $name . '
Subject: ' . $name . ' (' . $email . ')
Message:
' . $message ;
}
if (mail($recipient, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head)) {
header("Location: ../form-success.htm");
exit;
} else {
header("Location: ../form-error.htm");
exit;
}
?>
Does anyone know how to solve this?
Thanks for answers !
Aucun commentaire:
Enregistrer un commentaire