Page 1 of 1

Flash form mailed using php, need help...

Posted: Fri Jul 21, 2006 12:19 am
by WithHisStripes
Heya,
So if you visit http://www.hookmedia.biz/cabinet_source/v4_f you'll see my current project. If you fill out the two forms on the "Contact Us" page then it's emailed to wherever. But when the email shows up, all the content is on the same line, no spaces. Can anyone tell me how to make it so each one is on it's own line? Thanks!

Here's my PHP:

Code: Select all

<?php
$sendTo = "spencerhill@hookmedia.biz";
$subject = "Cabinet Source Contact Form Submission";
$headers = "From: " . $_POST["name"] ." " . $_POST[""]."";
$message = $_POST["comments"] . $_POST["phone"];
mail($sendTo, $subject, $message, $headers);

?>

Posted: Fri Jul 21, 2006 5:43 am
by andym01480
First up: Watch out populating the header with user input that hasn't been cleaned! Reject $_POST['name'] if it contains anything other than alphanumeric characters. Otherwise a user can send spam out very easily. Safest is to not put any user input in the headers!

The way I would do it is to format it as an html email

Code: Select all

$subject="Web Page form";
$headers = "MIME-Version: 1.0\r\n";
$headers .="Content-type: text/html; charset=iso-8859-1\r\n";
$headers .="From: web@hookmedia.biz\r\n";
$message= "<html><head><title>$subject</title></head><body>Web Page Contact Form<p><table>";
$message.="<tr><td>Name:</td><td>$_POST['name']</td></tr>";
$message.="<tr><td>Phone:</td><td>$_POST['phone']</td></tr>";
$message.="<tr><td>Message:</td><td>$_POST['comments']</td></tr>";
$message.="</table></body></html>";
mail($sendTo,$subject,$message,$headers) or die("Email couldn't be sent");

Posted: Fri Jul 21, 2006 5:46 am
by thomas777neo
use \n which is like a <br> in html