PDA

View Full Version : php not returning variables


DJB
05-27-2006, 06:17 PM
okay got my feedback form talking to the server with component fields-

theName
theEmail
theMessage

It now returns email successfully with headings-

name:
email:
message:

but doesnt include the user input under these fields. Is there something wrong with my php code -

<?PHP

$to = "mail@myaddress.co.uk";
$subject = "Website Feedback Form";
$message = "Name: " . $theName;
$message .= "\nEmail: " . $theEmail;
$message .= "\n\nMessage: " . $theMessage;
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk=" . $sentOk;

?>

bit of newbie when it comes to this so any help welcome as getting desperate - deadline in a few hours!!

ta very much.

D

Cota
05-27-2006, 06:36 PM
$to = "mail@myaddress.co.uk";
$subject = "Website Feedback Form";
$message = "Name: " . $_POST['theName'];
$message .= "\nEmail: " . $_POST['theEmail'];
$message .= "\n\nMessage: " . $_POST['theMessage'];
$headers = "From: ".$_POST['theEmail'];
$headers .= "\nReply-To:". $_POST['theEmail'];

$sentOk = mail($to,$subject,$message,$headers);

echo "&sentOk=" . $sentOk;

DJB
05-27-2006, 07:12 PM
Cota

You're a star - saved my life!:D

Ta

D

Flash Gordon
05-27-2006, 07:30 PM
And you say your not a PHP man :p

DJB
05-27-2006, 08:32 PM
ah well, I cobble other peoples efforts together!:eek:

does anyone know what code I need to add these variables to a database. i.e. it records the name, email and message in access or similar? this is definately beyond me...

Ta

D

Cota
05-27-2006, 10:09 PM
I've been learning PHP...here's a link that will help
http://aspn.activestate.com/ASPN/Cookbook/PHP/Recipe/163447