Page 1 of 1

Problem with mail()

Posted: Mon Apr 19, 2004 9:54 pm
by rkamun1
fellow warriors of the cathode tube,

I am kinda new to php and I am trying to use the send mail function to send mail. I am using data posted to the function from a form on the previous page. Now when I click send, I get the following errors

Notice: Undefined variable: subject in e:\inetpub\wwwroot\php\feedback.php on line 3

Notice: Undefined variable: message in e:\inetpub\wwwroot\php\feedback.php on line 3


I get the mail fine, but it has no subject and no body.....ok, so I guess I don't get it fine.

Is there something I am missing?[php_man][/php_man]

Posted: Mon Apr 19, 2004 9:58 pm
by John Cartwright
Firstly you are missing the part where you show us your code..

secondly it sounds as if you are not defining those variables :P

Posted: Mon Apr 19, 2004 10:01 pm
by rkamun1
//feedback.html
<html><title>Email the Webmaster</title>
<form name="form" method="post" action="feedback.php">
<p>To: <input type="text" name="subject"></p>
<p>Message: <textarea name="message"></textarea></p>
<input type="submit" name="Submit" value="Submit">
</form></html>


//feedback.php
<html><title>Email Sent to Webmaster</title>
<?php
mail("emailaddy", $subject, $message) ;
?></html>


the emailaddy will be changed....

Posted: Mon Apr 19, 2004 10:25 pm
by idotcom
//feedback.html
<html><title>Email the Webmaster</title>
<form name="form" method="post" action="feedback.php">
<p>To: <input type="text" name="subject"></p>
<p>Message: <textarea name="message"></textarea></p>
<input type="submit" name="Submit" value="Submit">
</form></html>


//feedback.php
<html><title>Email Sent to Webmaster</title>
<?php
mail("emailaddy", $subject, $message) ;
?></html>


Just so you know, you can post to the same page too. Just leave the form action empty or use <?=$PHP_SELF?>



<html>
<title>Email the Webmaster</title>
<body>
<form name="form" method="post" action="">
<p>To: <input type="text" name="subject"></p>
<p>Message: <textarea name="message"></textarea></p>
<input type="submit" name="Submit" value="Submit">
</form>
<? if($message)
{
mail("$email_to_address","$subject","$message"," From: feedback@site.com")

echo "Thank you for your feedback!";
}
?>
</body>
</html>


Hope this helps..