simple contact form problem

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
thelondonstyler
Forum Newbie
Posts: 3
Joined: Thu Mar 26, 2009 12:10 pm

simple contact form problem

Post 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.
Renier
Forum Newbie
Posts: 5
Joined: Wed Jan 13, 2010 1:41 am

Re: simple contact form problem

Post by Renier »

You're missing a . at the end of $name
ramblin54321
Forum Commoner
Posts: 32
Joined: Wed Nov 18, 2009 5:31 am

Re: simple contact form problem

Post by ramblin54321 »

line 9 put a dot after $name
thelondonstyler
Forum Newbie
Posts: 3
Joined: Thu Mar 26, 2009 12:10 pm

Re: simple contact form problem

Post by thelondonstyler »

thought it would be simple! that works great - thanks.
Post Reply