Forum Moderators: coopster

Message Too Old, No Replies

mail function ("else" not working)

having trouble with "else" in mail function

         

MasonShew

9:49 pm on Mar 10, 2005 (gmt 0)

10+ Year Member



I'm having trouble getting my error message to display.

The mail function works perfectly, too perfect. If a user submits a blank form, I want an error message to pop up. Instead, the user is still directed to the php document that says, "Thanks for your submission..." It even includes the space where the name would be inserted, had it been filled in.

The "else print..." is the chunk of code that doesn't seem to be working:

if(mail($recepient, $subject, $body, $additional_headers));
else print('There was an error processing your request. Please Try Again.')
?>

Any help would be greatly appreciated.

Mason

StupidScript

12:26 am on Mar 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome, MasonShew!

You should check for the elements of the mail, and for their correct formatting before invoking the mail() function.

mail() returns TRUE if it is accepted for delivery ... which doesn't mean that there's a "recipient" or a "subject" or a "body" in the function, just that it was accepted into your mail system. Just because it was accepted for delivery doesn't mean it will be delivered. :)

MasonShew

1:10 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



That makes sense. So maybe I'm approaching this the wrong way. Maybe I should probably be looking in to setting up required fields, as opposed to bool mail issues?

That, I think I can figure out.

Thanks for the help.

Mason

dreamcatcher

3:14 pm on Mar 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If a user submits a blank form, I want an error message to pop up

Sounds like you are after some javascript code if you want client side checking. Probably best to post in the javascript forum for that.

dc

MasonShew

4:26 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



Will do. Thanks!

Mason