Code:
<form method="POST" action="mailer2.php">
Name:
<input type="text" name="name" size="19"><br>
<br>
E-Mail:
<input type="text" name="email" size="19"><br>
<br>
<input type="checkbox" name="check[]" value="blue_color"> Blue<br>
<input type="checkbox" name="check[]" value="green_color"> Green<br>
<input type="checkbox" name="check[]" value="orange_color"> Orange<br>
<br>
Message:<br>
<textarea rows="9" name="message" cols="30"></textarea><br>
<br>
<input type="submit" value="Submit" name="submit">
</form>
PHP Code:
<?php
if(isset($_POST['submit'])) {
$to = "mail@mail.com";
$subject = "Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message\n $check_msg";
mail($to, $subject, $body);
if (mail($to, $subject, $body)) //if the mails sent
{ header(Location : "http://www.server.com/thanks.html");
}
//page to redirect to if your email was sent
else
{ echo "Sorry. Error sending message!";} //show that email could not be sent
?>