...

View Full Version : Undefined variable



andrew1234
04-14-2004, 03:17 PM
hi

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
http://www.cabc.co.za/testsite/testform.htm

Please can you help.

thanks

Andrew

<?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);
?>
<html>
<head>
<title>Order Confirmation</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>

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

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

bcarl314
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


$message="";


you should fix the problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum