RE: [PHP-WIN] $subject = "form results " causing problem
| From: | Mike | Date: | Wed, 02 Feb 2005 23:22:09 +0000 |
| Subject: | RE: [PHP-WIN] $subject = "form results " causing problem | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25513@lists.php.net to get a copy of this message | ||
Looks like you may be using the wrong format for the mail() function.
bool mail ( string to, string subject, string message [, string
additional_headers [, string additional_parameters]] )
http://us4.php.net/manual/en/function.mail.php
Reference the form you should be passing params and notice that the subject
should be the second param.
-M
> -----Original Message-----
> From: Patrick Roane [mailto:fojomo@sbcglobal.net]
> Sent: Wednesday, February 02, 2005 6:08 PM
> To: php-windows@lists.php.net
> Subject: [PHP-WIN] $subject = "form results " causing problem
>
> I was wondering why when I insert the $subject = "form
> results", I get the ...echo "Message failed to send";
>
> error.
>
> But when I comment this out, everything works fine.
> Please see below.
>
> <?php
> } else {
> error_reporting(0);
> // initialize a array to
> //hold any errors we encounter
> $errors = array();
>
> // test to see if the form was actually
> // posted from our form
> // In testing, if you get an Inavlid referer error
> // comment out or remove the next three lines
> $page =
> $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
> if (!ereg($page, $_SERVER['HTTP_REFERER']))
> $errors[] = "Invalid referer";
>
> // check to see if a name was entered
> if (!$_POST['from'])
> $errors[] = "Name is required";
> // check to see if email was entered
> if (!$_POST['email'])
> $errors[] = "a valid e-mail address is required";
> // if there are any errors, display them
> if (count($errors)>0) {
> foreach($errors as $err)
> echo "$err<br>\n";
> echo "<br>Please use your browser's Back button to fix.";
> } else {
> // no errors, so we build our message
> $subject = "form results";
> $recipient = 'fojomo@yahoo.com';
> $phone = stripslashes($_POST['phone']);
> $from = stripslashes($_POST['from']);
> $mail = stripslashes($_POST['email']);
> $comments = "Comments from:
> $from\n\n".stripslashes($_POST['comments']);
> if (mail($recipient, $comments, $phone, $mail, $subject)){
>