Re: Re: php form action breaks script
| From: | tamouse mailing lists | Date: | Thu, 28 Jun 2012 00:39:51 +0000 |
| Subject: | Re: Re: php form action breaks script | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318316@lists.php.net to get a copy of this message | ||
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy <bluethundr@gmail.com> wrote:
One more little thing:
These notices:
> Notice: Undefined index: subject in
> /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php
> on line 23 Notice: Undefined index: elvismail in
> /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php
show up because you are processing form fields in $_POST when there
might not be any yet.
These lines:
> $from = 'bluethundr@jokefire.com';
> $subject = $_POST['subject'];
> $text = $_POST['elvismail'];
> $output_form = "false";
Should appear *after* this line:
> if (isset($_POST['Submit'])) {
You should also check the $_POST entries for 'subject' and 'elvismail'
to make sure they are set to avoid the notices, even if you do move
them after the submit check. You never know!