PDA

View Full Version : Need Help Building Form Mailer Script


RyanB88
09-08-2007, 03:46 PM
All right, so I found this script online at http://www.thewebhelp.com/php/php_contact_form_with_image_validation/

but I needed to update it for my needs. I am keeping the image validation, but wanted to expand on the form. So I got these form fields:


name
home_phone
cell_phone
work_phone
email
contact_method
contact_time
issue
verif_box


I got this code so far:
<?php
// load the variables form the post
$from = $_POST["email"];
$verif_box = $_POST["verif_box"];
$name = $_POST["name"];
$home_phone = $_POST["home_phone"];
$cell_phone = $_POST["cell_phone"];
$work_phone = $_POST["work_phone"];
$contact_method = $_POST["contact_method"];
$contact_time = $_POST["contact_time"];
$issue = $_POST["issue"];

// build the message
$message = //this is where i need help

// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);

$from = stripslashes($from);

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show sucsess page
mail("ryan.bilesky@hotmail.com", 'Online Form', $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
header("Location: http://www.rcbitsolutions.com/contact/?sent");
} else {
// if verification code was incorrect then show error page
header("Location: http://www.rcbitsolutions.com/contact/?badverify");
exit;
}
?>

What i need is help building the message to be sent, to combine name, home_phone, cell_phone, work_phone, contact_method, contact_time, and issue into a readable message.

Thanks in advance for your help.

rafiki
09-08-2007, 03:53 PM
$message = 'cell phone #'.$cell_phone.' home phone #'.$home_phone.' etc...

RyanB88
09-08-2007, 03:59 PM
$message = 'cell phone #'.$cell_phone.' home phone #'.$home_phone.' etc...
thanks, just to clairify, I can include html in there to, to add line breaks, ect?

rafiki
09-08-2007, 04:03 PM
Example 1110. Sending HTML email

It is also possible to send HTML email with mail().
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";



http://www.php.net/manual/en/function.mail.php