Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Putting variables into the $body variable in mail()



10:35 pm on Aug 2, 2007 (gmt 0)

5+ Year Member

I'm working on an email form. It works until I add a variable to the $body variable contents. Can anyone see what I'm doing wrong? Here is a simplified version of what I'm doing:

$message = (isset($_POST['message'])? $_POST['message'] : '');
$email = "breeders@example.com";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:breeder@example.com\r\n";
$headers .= "Reply-To:" . $email . "\r\n";
$body = "
<p>Part of the body</p>
<p>" . $message . "</p>
if (isset($_POST['submit']))
mail('info@example.com', 'This Subject', $body, $headers);
<input type='text' name='message' size='20' value='' />
<input type='submit' value='test' />

[edited by: jatar_k at 1:06 am (utc) on Aug. 3, 2007]
[edit reason] no urls thanks [/edit]


11:33 pm on Aug 2, 2007 (gmt 0)

10+ Year Member

I think you may need to change <input type='submit' value='test' /> to add name="submit".


1:01 am on Aug 3, 2007 (gmt 0)

5+ Year Member

Good thinking barns101, thanks. That was the problem.

Featured Threads

Hot Threads This Week

Hot Threads This Month