Stopping an if clause along with the whole PHP script, but not HTML

Posted by user626816 on Stack Overflow See other posts from Stack Overflow or by user626816
Published on 2011-02-21T15:18:29Z Indexed on 2011/02/21 15:25 UTC
Read the original article Hit count: 179

Filed under:
|

Hello there,

I've been having this problem for around an hour, and have searched the internet for answers. I've checked the PHP documentation, looked around, Googled, nothing.

Anyways, my problem is that after I try to validate something (and it's wrong), if I use exit; it will also stop the HTML after. Here's what I'm talking about:

if ($_POST['exampleEmail'] == "")
{
    echo "Please enter an e-mail."; //Now I want only the PHP script to stop, however...
    exit; //If I use exit, then the HTML after this script (footer) doesn't show.
}

If anyone can help, please do. I've tried using break, but to no avail, since it's only for loops and switches.

If there is a better/more correct (or simply correct if this is the wrong way), please share. I've had this problem in the past, and I just used exit then.

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about exit