Adding extra fields to a Simple contact form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drog1998
Forum Newbie
Posts: 2
Joined: Sat Aug 21, 2010 3:27 am

Adding extra fields to a Simple contact form

Post 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.
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: Adding extra fields to a Simple contact form

Post 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
drog1998
Forum Newbie
Posts: 2
Joined: Sat Aug 21, 2010 3:27 am

Re: Adding extra fields to a Simple contact form

Post 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.
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: Adding extra fields to a Simple contact form

Post 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
Post Reply