homepage Welcome to WebmasterWorld Guest from 54.242.18.190
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Putting variables into the $body variable in mail()
horseatingweeds




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

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:

<?php
$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 = "
<html>
<head>
</head>
<body>
<p>Part of the body</p>
<p>" . $message . "</p>
</body>
</html>
";
if (isset($_POST['submit']))
{
mail('info@example.com', 'This Subject', $body, $headers);
}
?>
<form>
<input type='text' name='message' size='20' value='' />
<input type='submit' value='test' />
</form>

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

 

barns101




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

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

horseatingweeds




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

Good thinking barns101, thanks. That was the problem.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved