PHP Contact Form

Hello.

So I’ve downloaded a template and there was a built in contact form but I wanna know how to use it so the mails come to my email.

What should I change so the mail sends to my email?

Here’s the HTML:

<div class="contact-left">
        <div id="contact-form">

          <!--begin:notice message block-->
          <div id="note"></div>
          <!--begin:notice message block-->

          <form id="ajax-contact-form" method="post" action="javascript:alert('success!');">
            <div class="labels">
              <p>
                <label for="name">Namn</label>
                <br />
                <input class="required inpt" type="text" name="name" id="name" value="" />
              </p>
              <p>
                <label for="email">E-Mail</label>
                <br />
                <input class="required inpt" type="text" name="email" id="email" value="" />
              </p>
            </div>
            <div class="comments">
              <p>
                <textarea class="textbox" name="message" rows="6" cols="30"></textarea>
              </p>
              <br />
              <p>
                <label for="answer">5+1=?</label>
                <br />
                <input class="required inpt" type="text" name="answer" id="answer" value="" />
              </p>
            </div>
            <label id="load" style="display:none"></label>
            <input id="submit-button" class="button gray stripe" type="submit" name="submit" value="Skicka brev" />
          </form>
        </div>
        <!-- End Form -->
      </div>

Here’s the PHP:

<?php

// Do not edit this if you are not familiar with php
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;

$replyto='yourname@yourdomain.com';
$subject = 'Contact Form Results';

if($post)
	{
	function ValidateEmail($email)
	{

$regex = "([a-z0-9_\\.\\-]+)". # name

"@". # at

"([a-z0-9\\.\\-]+){2,255}". # domain & possibly subdomains

"\\.". # period

"([a-z]+){2,10}"; # domain extension

$eregi = eregi_replace($regex, '', $email);

return empty($eregi) ? true : false;
}

$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);

$message = stripslashes($_POST['message']);
$phone = stripslashes($_POST['phone']);
$answer = trim($_POST['answer']);
$verificationanswer="6"; // plz change edit your human answer
$from=$email;
$to=$replyto;
$error = '';
$headers= "From: $name <" . $email . "> \
";
$headers.= "Reply-to:" . $email . "\
";
$headers .= 'MIME-Version: 1.0' . "\\r\
";
$headers = "Content-Type: text/html; charset=utf-8\
".$headers;

// Checks Name Field

if(!$name || !$email || $email && !ValidateEmail($email) || $answer <> $verificationanswer || !$message || strlen($message) < 1)
{
$error .= 'Please fill the required fields correctly.<br />';
}

if(!$error)
	{
$messages.="Name: $name <br>";
$messages.="Email: $email <br>";
$messages.="Message: $message <br>";

	$mail = mail($to,$subject,$messages,$headers);	

if($mail)
	{
	echo 'OK';
if($autorespond == "yes")
{
	include("autoresponde.php");
}
	}

	}
	else
	{
	echo '<div class="error">'.$error.'</div>';
	}

}
?>

Thanks!

Where the code is:
$replyto=‘yourname@yourdomain.com’;
Change email to your own.
Or
$replyto=‘put here@what ever the domain is.com’;

The action=“” attribute of your form ( <form [COLOR="#FF8C00"]action=""[/COLOR]> ) needs to point to your PHP script.

Yeah, now everything works. Thanks dudes!

Cool!

Off Topic:

PS: “wanna” is as bad as “gonna”, if not worse. :smiley: