Page 1 of 1

simple contact form problem

Posted: Wed Jan 13, 2010 3:45 am
by thelondonstyler
Hi,

This should be simple but..as a newbie:

I have created a simple php script for a contact form. I want to include dynamic content in the $message field, although it seems to only allow normal text:

This works:

Code: Select all

$message = ("Hi,</br></br>Your friend wanted to share our website, http://www.example.com with you. We hope you find it interesting!.</br></br>Kind Regards</br>example.com");
This doesn't:

Code: Select all

$message = ("Hi,</br></br> "[color=#BF0000].$name[/color]"wanted to share our website, http://www.example.com with you. We hope you find it interesting!.</br></br>Kind Regards</br>Example.com");
Full code:

Code: Select all

<?php
if(isset($_POST['submit'])) {
 
$email = $_POST['email'];
$name = $_POST['name'];
 
$to = $email;
$subject = ("recommendation from: ".$name);
$message = ("Hi,</br></br> ".$name"wanted to share our website, http://www.example.com with you. We hope you find it interesting!.</br></br>Kind Regards</br>example.com");
$header = ("From:Recommendation from: ".$name);
 
if(mail($to,$subject,$message,$header)) {
$result = "Many thanks for recommending us to a friend";
} else {
$result = "<h3>Error sending your message.</h3>
        Sorry, an error occured sending.<br />Please try again later or contact us direct to be added to the mailing list";
}}
?>
I'm sure this is easy!

Thanks in advance.

Re: simple contact form problem

Posted: Wed Jan 13, 2010 3:56 am
by Renier
You're missing a . at the end of $name

Re: simple contact form problem

Posted: Wed Jan 13, 2010 3:56 am
by ramblin54321
line 9 put a dot after $name

Re: simple contact form problem

Posted: Wed Jan 13, 2010 4:07 am
by thelondonstyler
thought it would be simple! that works great - thanks.