...

View Full Version : Php form mail.



maverick4546
01-13-2010, 11:01 PM
Hi all... and firstly let me apologise for my newbieness :o

I am building a site for a friend at www.oldcastlehotel.co.uk

I have built a form (basic but all thats needed)

when it comes to the form handler I have a file called mail.php which the enquire.htm file calls on when the form is submitted.

this is the original form..

<?
$to = 'me@mydomain.com';
$subject = 'subject';
$message = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
$email = $_REQUEST['email'];
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail ($to, $subject, $message, $headers);
header("Location: thanks.html");
?>

When this script is used the form works ok but not all the fields on the form are emailed.. all I get is the name, email and the first option.

All I want to do is add the form fields which are data1, data2, data3 and data4 to the php side and I am struggling a bit.

I am new to php... but wanna learn. Any help from anyone? please!

John

mlseim
01-13-2010, 11:27 PM
You're missing some of the form variables ...
Plus ... $_REQUEST should no longer be used ...



<?
$to = 'me@mydomain.com';
$subject = 'subject';
$contact = $_POST['data1'];
$enquiry = $_POST['data'];
$dates = $_POST['data3'];
$text = $_POST['data4'];
$email = $_POST['email'];

$message = "From: " . $contact . "\n\n"
. "Enquiry:" . $enquiry ."\n\n"
. "Dates:" . $dates ."\n\n"
. "Text:" . $text ."\n\n";

$headers = "From: " . $email . "\r\n" .
"Reply-To: " . $email . "\r\n" .
"X-Mailer: PHP/" . phpversion();

mail ($to, $subject, $message, $headers);
header("Location: thanks.html");
?>

maverick4546
01-13-2010, 11:50 PM
Cheers for that... I have been playing some more and got this php script.

<?
$to = 'johnzo@live.co.uk';
$subject = 'subject';
$contact = $_POST['name'];
$telephone = $_POST['number'];
$enqtype = $_POST['enqtype'];
$dates = $_POST['dates'];
$other = $_POST['Otherinfo'];
$email = $_POST['email'];

$message = "From: " . $contact . "\n\n"
. "Enquiry:" . $enquiry ."\n\n"
. "Dates:" . $dates ."\n\n"
. "Text:" . $text ."\n\n"
. "Other:" . $other ."\n\n";

$headers = "From: " . $email . "\r\n" .
"Reply-To: " . $email . "\r\n" .
"X-Mailer: PHP/" . phpversion();

mail ($to, $subject, $message, $headers);
header("Location: thanks.html");
?>

But the email comes back when its filled in on the site as...

From: Warby

Enquiry:

Dates:

Text:

all the out puts are blank... any ideas.. sorry for being stupid :D

maverick4546
01-13-2010, 11:58 PM
THANK YOU MY FRIEND!

All sorted out now :)

cheers again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum