innercproductions
asked on
PHP die() - messes up footer on page
I have a script that does a check on an input form.
If the field is empty, I have it set to die($errormsg) in order to stop the script.
The message tells them that there was an error and give a link back.
But this also stops the include of the footer on the page.
How can I stop the script from doing everything.. but still show the footer.
Ideas?
If the field is empty, I have it set to die($errormsg) in order to stop the script.
The message tells them that there was an error and give a link back.
But this also stops the include of the footer on the page.
How can I stop the script from doing everything.. but still show the footer.
Ideas?
you can put the footer in a separate file and then something like this:.
<?php
if ($invalidform)
{
require('footer.php');
die($errormsg);
}
//the code if the form is ok
require('footer.php');
?>
<?php
if ($invalidform)
{
require('footer.php');
die($errormsg);
}
//the code if the form is ok
require('footer.php');
?>
or you can create a function with the footer inside and call it. There are many ways to solve this.
ASKER
Wouldn't this put the error message AFTER the footer administradores?
And to bahadirkocaoglu...
Using DEFINE... how would I replace this?
"$result = mysql_query($query) or die ($database_errorinquery);"
And to bahadirkocaoglu...
Using DEFINE... how would I replace this?
"$result = mysql_query($query) or die ($database_errorinquery);"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please do not use die, you can check your order form via define/defined.
For more:
www.php.net/define
www.php.net/defined