undefined variable query

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
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

undefined variable query

Post by Addos »

Hi, I keep getting the error ‘undefined variable’ which is referring to $to from this bit of code below when I try to submit my page.
Can anyone tell me what is wrong as I have used this on other pages on other sites and don’t get this error?
Any help would be great
Thanks
Brian

Code: Select all

$from = 'Snazzy Dogz' . "\r\n";
	$subject = 'Message from your Web Site ' . "\r\n";
	$headers = "To: Snazzy Dogz <info@blah.com>, Admin<info@blah.com> \r\n";
	$headers .= "from: $from\n";
	$message =  $_POST['Name']. ' is requesting some information from you.' . "\r\n";
	$message .=  ' ' . "\r\n";
	$message .= 'The Subject is: ' .$_POST['Subject']. "\r\n";
    $message .=  ' ' . "\r\n";
	$message .= 'They wrote: ' ."$messagedetails". "\r\n";
	$message .=  '' . "\r\n";
	$message .= 'You can email them back at: ' .$_POST['Email']. "\r\n";
	$message .=  ' ' . "\r\n";
	$message .=  ' ' . "\r\n";
	$message .=  ' ' . "\r\n";
	$message .= 'This email has been automatically generated. Please do not reply to it.' . "\r\n";
  mail($to,$subject,$message,$headers);
  header('Location: contact_act.php');
  exit();
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

$to isn't set in that code.. hence it's being reported as undefined.
Post Reply