Flash form mailed using php, need help...

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
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Flash form mailed using php, need help...

Post 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);

?>
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post 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");
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

use \n which is like a <br> in html
Post Reply