Page 1 of 1

Adding extra fields to a Simple contact form

Posted: Sat Aug 21, 2010 3:37 am
by drog1998
Hi everybody,

i'm using a simple contact form which uses Flash and PHP.

At the moment it does every thing it's supposed to, like forwarding the message to my email etc. but i need to add a few extra fields.

I have few fields labeled 'message', 'telephone' and 'time' but only the details in the message field get delivered to my email

How do i add in 'telephone' and 'time' to the code below?




Here's the PHP i'm using

Code: Select all

<?php
$sendTo = "myemail@hotmail.com";
$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = $_POST["message"];

mail($sendTo, $subject, $message, $headers);
?>
Thanks.

Re: Adding extra fields to a Simple contact form

Posted: Sat Aug 21, 2010 4:54 am
by iijb
Hi,
You just append the your required fields to the variable message. Like,

Code: Select all

$message ='Message: '. $_POST["message"].' Phone no: '. $_POST["telephone"];
Regards
iijb

Re: Adding extra fields to a Simple contact form

Posted: Sat Aug 21, 2010 8:07 am
by drog1998
iijb, thank you so much. i've been trying to figure that out for hours.

one last question... is there a way to get the information on seperate lines?

at the moment its like this...

Name: Darrell Phone: 6666 6666 etc.

is it possible to make it go like this....

Name: Darrell
Phone: 6666 6666 etc.

Re: Adding extra fields to a Simple contact form

Posted: Sat Aug 21, 2010 10:48 pm
by iijb
Hi,
Yes sure you can achieve that by sending your email in html format. So that you can nicely format your mail. Try this
http://php.net/manual/en/function.mail.php.

Regards
iijb