Hi I have recently built a website for a friend and have included a contact page form. is it possible to adapt the php to collect the subject as typed by the sender to appear as the subject as would appear on an email header. At the moment it is limited to the fixed name $emailSubject = 'contact_form!';This is the script I am using
<?php
/* Email Variables */
$emailSubject = 'contact_form!';
$webMaster = 'example@example.com';
/* Data Variables */
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$comments = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Subject: $subject<br>
Comments: $comments <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://example.com/contact.html">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">Your email will be answered soon as possible!
You will return to example.com in few seconds !</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
Thankyou
Paul
[edited by: tedster at 5:02 am (utc) on Jan 28, 2012]
[edit reason] switch to example.com [/edit]