I bought a theme from theme forest to further build it with html and css.
However there is a contact form which I have no idea how to use. I'm beginner in php and javascript. I thought that I should just insert my email address to: //ENTER YOUR EMAIL ADDRESS HERE $address = '[email protected]';
. But this did not workout.
My question is: How do I make this work so that when somebody try to contact me by filling the contact form I will receive the mail to my email address. I tested by myself on my local server, I don't receive any mail when I tried to fill the contact form.. Anyone please bring me to the right direction.
<?php
if(!$_POST) exit;
function tommus_email_validate($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email); }
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$comments = $_POST['comments'];
if(trim($name) == '') {
exit('<div class="alert danger">Attention! You must enter your name.</div>');
} else if(trim($name) == 'Name') {
exit('<div class="alert danger">Attention! You must enter your name.</div>');
} else if(trim($email) == '') {
exit('<div class="alert danger">Attention! Please enter a valid email address.</div>');
} else if(!tommus_email_validate($email)) {
exit('<div class="alert danger">Attention! You have entered an invalid e-mail address.</div>');
} else if(trim($website) == 'Website') {
exit('<div class="alert danger">Attention! Please enter your website.</div>');
} else if(trim($website) == '') {
exit('<div class="alert danger">Attention! Please enter your website.</div>');
} else if(trim($comments) == 'Message') {
exit('<div class="alert danger">Attention! Please enter your message.</div>');
} else if(trim($comments) == '') {
exit('<div class="alert danger">Attention! Please enter your message.</div>');
} else if( strpos($comments, 'href') !== false ) {
exit('<div class="alert danger">Attention! Please leave links as plain text.</div>');
} else if( strpos($comments, '[url') !== false ) {
exit('<div class="alert danger">Attention! Please leave links as plain text.</div>');
} if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); }
//ENTER YOUR EMAIL ADDRESS HERE
$address = '[email protected]';
$e_subject = 'You\'ve been contacted by ' . $name . '.';
$e_body = "You have been contacted by $name from $website from your contact form, their additional message is as follows." . "\r\n" . "\r\n";
$e_content = "\"$comments\"" . "\r\n" . "\r\n";
$e_reply = "You can contact $name via email, $email";
$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
$headers = "From: $address" . "\r\n";
$headers .= "Reply-To: $email" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=utf-8" . "\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable" . "\r\n";
if(mail($address, $e_subject, $msg, $headers)) {
echo "<fieldset><div id='success_page'><h4 class='remove-bottom'>Email Sent Successfully.</h4><p>Thank you <strong>$name</strong>, your message has been submitted to us.</p></div></fieldset>";
}
<section id="contact" class="page-section dark-wrapper">
<div class="container">
<div class="row">
<div class="page-header text-center">
<!-- multiple h1's are perfectly acceptable on a page in valid HTML5, when wrapped in individual sections, they're 100% semantically correct -->
<h1>Contact Me<small>Here's a Working Contact Form</small></h1>
<!-- seriously -->
</div>
<div class="col-sm-8">
<div id="message"></div>
<form method="post" action="sendemail.php" id="contactform">
<input type="text" name="name" id="name" placeholder="Name" />
<input type="text" name="email" id="email" placeholder="Email" />
<input type="text" name="website" id="website" placeholder="Website" />
<textarea name="comments" id="comments" placeholder="Comments"></textarea>
<input type="submit" name="submit" value="Submit" />
</form>
</div>
<div class="col-sm-4 lp30">
<h5>Contact Me</h5>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar.</p>
<ul class="fa-ul">
<li class="bm15"><i class="fa fa-map-marker fa-fw fa-2x fa-li"></i> Denmark</li>
<li class="bm15"><i class="fa fa-phone-square fa-fw fa-2x fa-li"></i> 08044576869</li>
<li class="bm15"><i class="fa fa-laptop fa-fw fa-2x fa-li"></i> <a href="mailto:[email protected]" target="_top">[email protected]</a></li>
</ul>
</div>
</div>
</div>
</section>