Hi all, firstly thank you in advance to anyone who replies to this thread. I'll be honest I'm a newbie when I comes to PHP and really am a long way to mastering it. If someone could have a look at my code and tell me where I'm going wrong here then it would be a great help.
The problem here is, when I click on the submit button it sends me to the PHP script page and doesn't actually send a email to the address.
Please Help and again, thank you in advance.
Below is the HTML,
<section>
<div class="container">
<div class="row">
<div class="col-lg-2 col-lg-offset-5">
<hr class="marginbot-50">
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="boxed-grey">
<form data-toggle="validator" role="form" method="post" action="email/contactus.php">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">
Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter name" required="required" />
</div>
<div class="form-group">
<label for="email">
Email Address</label>
<div class="clearfix"></div>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span>
</span>
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email" required="required" /></div>
</div>
<div class="form-group">
<label for="contact">
Who would you like to contact?</label>
<select id="contact" name="contact" class="form-control" required="required">
<option value="" selected="">Choose One:</option>
<option value="Club Chairman">Club Chairman</option>
<option value="Sponsorship Secretary">Sponsorship Secretary</option>
<option value="Club Captain">Club Captain</option>
<option value="Club Website Administrator">Club Website Administrator</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="name">
Message</label>
<textarea name="message" id="message" class="form-control" rows="9" cols="25" required="required"
placeholder="Message"></textarea>
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-skin pull-right" id="btnContactUs">
Send Your Message</button>
</div>
</div>
</form>
</div>
</div>
<div class="col-lg-4">
<div class="widget-contact">
<h5>Write to us</h5>
<address>
<strong>Abberton & District Cricket Club</strong><br>
The Brow<br>Abberton Road<br>Colchester<br>Essex<br>CO5 7AW<br>
<abbr title="Phone"><span class="glyphicon glyphicon-phone-alt"></span></abbr> (01206) 735244
</address>
<address>
<strong>Email</strong><br>
<a href="mailto:#">
[email protected]</a>
</address>
<address>
<strong>We're on social networks</strong><br>
<ul class="company-social">
<li class="social-facebook"><a href="#" target="_blank"><i class="fa fa-facebook"></i></a></li>
<li class="social-twitter"><a href="#" target="_blank"><i class="fa fa-twitter"></i></a></li>
</ul>
</address>
</div>
</div>
</div>
</div>
</section>
The PHP I have is:
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$person = $_POST['contact'];
$about = $_POST['about'];
$query = $_POST['message'];
$email_from = $name.'<'.$email.'>';
$to="
[email protected]";
$subject="Message from abbertoncricket website";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$email_from."\r\n";
$message="
Hi, My name is $name.
<br>
I'm looking to contact the <b>$person</b> for your cricket club.
<br>
The subject title for my message is $about
<br>
My message is $query
<br>
If you need to contact me further about this matter then please contact me via my email address below
$email
<br>
Thank you.
$name
";
if(mail($to,$subject,$message,$headers))
header("Location:../../index.html?msg=Successful Submission! Thankyou for contacting us.");
else
header("Location:../contact.html?msg=Error To send Email !");
}
?>
Again, thankyou for your help.
Sam Truss