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]
Problem with mail()
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
//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....
<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....
//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..
<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..