Forum Moderators: coopster

Message Too Old, No Replies

php subject line

Help needed with script

         

Paul_C171

2:06 am on Jan 28, 2012 (gmt 0)

10+ Year Member



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]

penders

9:52 am on Jan 28, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here is a clue...

$emailSubject = 'contact_form!'; 
:
$subject = $_POST['subject']; // Subject typed into form
:
$success = mail($webMaster, $emailSubject, $body, $headers);


:)

Paul_C171

9:59 pm on Jan 28, 2012 (gmt 0)

10+ Year Member



Thank you. That was helpfull.

Paul