I am not certain why the following code is not working. When the submit button is pushed it will clear the form, but not send an email. (Please note I copied the code from my dreamweaver program). Have virtually the same code on another server and it is working, but this one is not working. I am not sure why.
<!-- BEGIN FORM -->
<p class="body-text">Fields marked with an * are required. </p>
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" enctype="multipart/form-data" method="POST" class="body-text">
Name: <br /><input name="name" type="text" size="30" /> *<br />
<!--Last Name: <br /><input name="Last-Name" type="text" size="30" required> *<br> -->
Email: <br /><input name="email" type="text" size="50" /> *<br />
Event Type: <br />
<label>
<select name="eventtype" class="body-text" id="type" width="30">
<option>Camp event</option>
<option>Brigade event</option>
<option>Division event</option>
<option>National event</option>
</select>
</label> *<br />
Message: <br /><textarea name="message" cols="50" rows="10"></textarea> *<br />
<!--<input type="hidden" name="sendtoemail"><br /> -->
<input type="submit" value="Send Form" /><br />
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$event=$_REQUEST['eventtype'];
$message=$_REQUEST['message'];
$to="[email protected]";
$link_address = 'www.alscv.org/events.html';
if (($name=="")||($email=="")||($event=="")||($message="")) /* required fields */
{
echo "All fields are required. Please fill <a href='$link_address'>Link</a> again";
/*echo "All fields are required. Please fill <a href=\"\">the form</a> again.";*/
}
else
{
$from="From: $name<$email>\r\nReturn-path: $email"; /* who the email is from */
$subject="AL Division SCV Event Form Message"; /* email subject */
$emailmessage=$name."\r\n".$email."\r\n".$event."\r\n".$message; /* builds email message */
mail($to, $subject, $from, $emailmessage); /* sends mail to email address and what is sent */
echo "Email sent!";
}
}
?>