Page 1 of 1

Hopefully a simple php problem ( exit() function)

Posted: Sat Jun 18, 2005 10:49 pm
by Monty
Hello,

I'm making a login system in php.
In my registration form, after i press submit button, i do some checks for valid email adres, password safety, etc..
Now if for example the users email adres is not valid, i execute this:

die('Invalid e-mail address.');

This php code is located in a html. The problem is that all the html code after the DIE function does not display... So the table looks completely messed up.
Is there a way to jump out of php code, but still render the remaining html below the code?


Thank you.

Posted: Sat Jun 18, 2005 10:54 pm
by nigma
Instead of die, use some conditionals:

Code: Select all

if (everything in forum is valid) {
  // do registration
} else {
  echo 'Invalid xxx';
}

Posted: Sat Jun 18, 2005 10:55 pm
by hawleyjr
There are many ways. Post your code and we'll help.

Code: Select all

if($xyz == 'abc')
echo '<b>MY HTML</b>';
else
echo '<I>Nope</I>';

Posted: Sun Jun 19, 2005 12:26 am
by Ambush Commander
Simply put, seperate your application code from your display code. That way, if you hit a problem while processing your data, you can throw a message without worrying about data you've already echo'd.

Posted: Sun Jun 19, 2005 8:04 pm
by Monty
OK
great!
using echo seems to make more sense for this :)

Thanx peoples