View Full Version : Undefined variable

04-14-2004, 03:17 PM

My php send mail script says after the form is submited

"Notice: Undefined variable: message in d:\inetpub\wwwroot\cabc.co.za\testsite\sending.php on line 20
sent "

below is my script: why am i getting this error .. because
I receive the mail from the form

Please can you help.



<?php // <---- you need full open tags, not short ones

header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

header ('Last-Modified: '.gmdate ('D, d M Y H:i:s').' GMT');
header ('Cache-Control: no-store, no-cache, must-revalidate');
header ('Cache-Control: post-check=0, pre-check=0', false);
header ('Pragma: no-cache');

$txtTo = "andrew@hamandmushroom.co.za";
$txtFrom = sprintf ("From: %s \r\n", $_POST['Email_Address']);
$subject = "sub newway ";
$header = "header new way \n\n";
$footer = "footer new way \n";

// continue with rest of form...
$message .= sprintf ("Name : %s \n\n", $_POST['Name']);
$message .= sprintf ("E-mail : %s \n\n", $_POST['Email_Address']);
$message .= sprintf ("Address : %s \n", $_POST['Address']);

mail ($txtTo, $subject, $header.$message.$footer, $txtFrom);
<title>Order Confirmation</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<!-- confermation page starts here below this...// -->

<!-- REMEMBER to make the form send button to go to this file...// -->

04-14-2004, 04:11 PM
It's only a notice.

The problem is you're appending data to a variable without initially declaring that it exists.

If you started your code with a


you should fix the problem.