I am working on a contact page on my website and for some reason, I don't know what I'm doing wrong... Typical case haha. I'm sure its right under my nose, but for the life of me I can't figure it out.
Anyway here is the snip.
send_email.php
and of course I have the appropriate JS files located on the server. So my problem is when its all put together, it doesn't work... Any ideas ? This is what it looks like. I am obviously doing something wrong because its showing "fail / success" at the botton left. before even doing anything. Any help would be great. Thanks.
Also the send button is supposed to be under the message field... What a head ache.
Anyway here is the snip.
PHP:
<html>
<body>
<!-- Contact Page -->
<div id="contact">
<div class="inner-content clearfix">
<h1>Get in touch!</h1>
<?php
<form id="contact-form">
<form action="send_email.php" method="post" id="contactForm">
<div>
<input type="text" name="name" class="form required" id="name" placeholder="Name or Company" value="" />
</div>
<div>
<input type="text" name="email" class="form required email" id="email" placeholder="E-mail address" value="" />
</div>
<div>
<textarea cols="40" rows="8" name="message" class="form required" id="message" placeholder=Ask a question"></textarea>
</div>
<div class="clear"></div>
</div>
<div class="oh">
<input class="button" type="submit" value="Send" />
<div id="loader"></div>
<span id="result">
<span class="success">Email sent correctly</span>
<span class="fail">Some errors occurred, please try again</span> ?>
</form>
</div>
</div>
<!-- End Contact Page -->
</body>
[/HTML]
send_email.php
PHP:
<?php
//Insert your email address
$mailTo = "[email protected]";
//Insert the subject of the email
$subject = "Message from Website";
if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['message']))
{
$name = htmlspecialchars(urldecode($_POST['name']));
$mailFrom = htmlspecialchars(urldecode($_POST['email']));
$message_text = htmlspecialchars($_POST['message']);
$headers = 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: '.$mailFrom;
$message = "<html>
<head>
<title> $subject </title>
</head>
<body>
<b>Name/Company name:</b> $name<br /><br />
<b>E-mail:</b> $mailFrom<br /><br />";
$message .= "<b>Message:</b><br />
<p>$message_text</p>
</body>
</html>";
if (mail($mailTo, $subject, $message, $headers))
echo "email sent";
else {
echo "Some errors occurred, try again.";
}
}
?>
and of course I have the appropriate JS files located on the server. So my problem is when its all put together, it doesn't work... Any ideas ? This is what it looks like. I am obviously doing something wrong because its showing "fail / success" at the botton left. before even doing anything. Any help would be great. Thanks.
Also the send button is supposed to be under the message field... What a head ache.