Contact form question
Posted: Sun Jul 11, 2010 1:08 pm
Hello,
I'm sure this probably the easiest question you'll have ever had on this forum but can anyone tell me how I can change the actual email content that is sent out using a contact form I have put on my site? At the moment All I get in the email that is sent out when the form is submitted is the actual message. What I would ideally like in the email is something like this:
Name: John Smith
Email: john@smith.com
Phone: 1234 5678
Message:
Hello, this is my message.
Below is the contact form php code:
Any help would be greatly appreciated as I've never done anything with PHP before.
Thanks in advance.
I'm sure this probably the easiest question you'll have ever had on this forum but can anyone tell me how I can change the actual email content that is sent out using a contact form I have put on my site? At the moment All I get in the email that is sent out when the form is submitted is the actual message. What I would ideally like in the email is something like this:
Name: John Smith
Email: john@smith.com
Phone: 1234 5678
Message:
Hello, this is my message.
Below is the contact form php code:
Code: Select all
<?php
include 'config.php';
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{
include 'functions.php';
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$phone = stripslashes($_POST['phone']);
$subject = 'Website contact form';
$message = stripslashes($_POST['message']);
$error = '';
// Check name
if(!$name)
{
$error .= '<li>Please enter your name.</li>';
}
// Check email
if(!$email)
{
$error .= '<li>Please enter an email address.</li>';
}
if($email && !ValidateEmail($email))
{
$error .= '<li>Please enter a valid e-mail address</li>';
}
// Check message (length)
if(!$message)
{
$error .= "<li>Please enter your message</li>";
}
if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail)
{
echo 'OK';
}
}
else
{
echo '<div class="notification_error"><ul>'.$error.'</ul></div>';
}
}
?>Thanks in advance.