The form and the PHP code are working fine, but the only problem I am having with this is that it will not send an email to me nor to the person signing up. Please if you could look at the codes to see what I am doing wrong.
Thanks in advance.
This the HTML.
<div id="formWrapper">
<form action="formprocess.php" method="post">
<fieldset class="first">
<h3>Welcome to the SBOCC Questions & Comments Page.</h3>
<h4>Please fill out the form below with your question(s) or comment(s)<br>
so that you may receive an answer. Shalom (Peace). BLESS THE COMFORTER.
</h4>
<label class="labelOne" for="name">Your Name:</label>
<label class="two" for="optional">(Required)</label>
<input name="name" />
<label for="email">Your Email:</label>
<label class="three" for="required">(Required)</label>
<input name="email" />
<label for="questionscomments">Questions/Comments:</label>
<textarea name="speak"></textarea>
</fieldset>
<fieldset>
<input class="btn" name="submit" type="submit" value="Send Email" />
<input class="btn" name="reset" type="reset" value="Clear Form" />
</fieldset>
<fieldset class="second">
<h4>Would you like to be added to our mailing list?<h4>
<input class="ckbox" type="checkbox" name="mailing" value="yes" checked="yes" /> Yes
<input class="ckbox" type="checkbox" name="mailing" value="no" /> No
</fieldset>
And these are the PHP codes:
<?php
$to = "shealtielyisrael@gmail.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = "Contact The SBOCC";
$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"speak"} = "questions/comments";
$fields{"mailing"} = "newsletter";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b)
{$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@thesbocc.com";
$subject2 = "Thank you for contacting The SBOCC";
$autoreply = "Thank you for contacting us. Your question(s)/comment(s) has been received. Shalom. Bless the comforter";
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: thankyou.html");}
else
{print "We encountered an error sending your mail, please notify shealtielyisrael@gmail.com";}
}
}
?>