I would like to have a contact form on my website That I am creating for college.. When I enter the information and click on submit, It shows my PHP code and does not send me an email... I am using a sample template for a contact form with some slight adjustments such as my email...
Can anyone help me please? I have the HTML code and PHP code below
<html>
<div id="ContactForm">
<div id="message"></div>
<form method="post" action="contact.php" id="contactform">
<fieldset>
<legend>ContactForm</legend>
<label for="name" accesskey="U">Your Name: <span class="required">*</span></label>
<input name="name" type="text" id="name" size="30" value="" />
<br />
<label for="email" accesskey="E">Your Email: <span class="required">*</span></label>
<input name="email" type="text" id="email" size="30" value="" />
<br />
<label for="comments" accesskey="C">Your Message: <span class="required">*</span></label>
<textarea name="comments" cols="120" rows="11" id="comments"></textarea>
<br />
<label for="verify" accesskey="V">3 + 1 = <span class="required">*</span></label>
<input type="submit" class="submit" id="submit" value="Submit" />
<input name="verify" type="text" id="verify" size="3" value="" style="width: 30px;" /><input type="submit" class="submit" id="submit" value="Submit" />
</fieldset>
</form>
</div>
</html>
--------------------------------------------------------------------------------------------------
<?php
if(isset($_POST['submit'])) {
$to = "tombrachio@gmail.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail: $to, $subject, $body);
} else {
echo "blarg!";
}
?>
Thank you