I've been scouring the countless other php contact form questions for the past five hours and can't for the life of me figure out why mine isn't working. I'm a total newbie to PHP other than some 'lessons' from Codecademy. So - here's what we've got. Single page HTML file. Here's the form:
<div id="contact-form-section">
<div class="status alert alert-success" style="display: none"></div>
<form id="contact-form" class="contact" name="contact-form" method="post" action="send-mail.php">
<div class="form-group">
<input type="text" name="name" class="form-control name-field" required="required" placeholder="Your Name"></div>
<div class="form-group">
<input type="email" name="email" class="form-control mail-field" required="required" placeholder="Your Email">
</div>
<div class="form-group">
<input type="text" name="tel" class="form-control" required="required" placeholder="Your Phone Number">
</div>
<div class="form-group">
<textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Message"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Send</button>
</div>
</form>
</div>
And here's the php, with the email I wanted to send to replaced by example@example.com. Trying to figure out from some other tutorials mopped together to figure out how it works. Wanted to have the submit button fire the alert, then go back to the index page.
<?
$name=$_POST['name'];
$Email=$_POST['email'];
$tel=$_POST['tel']
$website=$_POST['url'];
$message=$_POST['message'];
$body .= "Name: " . $name . "\n";
$body .= "Email: " . $Email . "\n";
$body .= "Telephone: " . $tel . "\n";
$body .= "Website: " . $website . "\n";
$body .= "Message: " . $message . "\n";
//Receiving email
mail("example@example.com","New email",$body);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>alert("Your message has been sent successfully. We will contact you shortly.");</script>
<meta HTTP-EQUIV="REFRESH" content="0; url=index.html">
</head>
What am I doing wrong here? Whenever I click on the submit button, it brings my to my send-mail.php page, but no notification comes up, and the email doesn't send. Any help is greatly appreciated, I know these questions come up far too often on Stack - like I said, I spent five hours sifting through contact form questions trying to figure out what I screwed up on here.