Link to home
Start Free TrialLog in
Avatar of innercproductions
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?
Avatar of bahadirkocaoglu
bahadirkocaoglu
Flag of Türkiye image

You can use DEFINE / DEFINED constants instead die() function.

Please do not use die, you can check your order form via define/defined.

For more:
www.php.net/define
www.php.net/defined
Avatar of administradores
administradores

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');
?>

or you can create a function with the footer inside and call it. There are many ways to solve this.
Avatar of innercproductions

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);"


ASKER CERTIFIED SOLUTION
Avatar of steelseth12
steelseth12
Flag of Cyprus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial