Jump to content

Archived

This topic is now archived and is closed to further replies.

chris_davidsonuk

PHP DIE Function

Recommended Posts

I am using login script I found at http://www.free2code.net/plugins/articles/read.php?id=99. It uses 'DIE' to stop the script when a username or password is incorrect.

The problem I am having is that I have my menu at the bottom of the page which I include into the page. But if the user dosn't enter the correct username and password the script is terminated so the menu doesn't show.

[code]
if(!$_POST['uname'] | !$_POST['passwd']) {

die('You did not fill in a required field.<br>');

}
[/code]

Is there anyway to include my footer file (footer.php) even if the script has 'DIED' ?

Share this post


Link to post
Share on other sites
no
DIE() and EXIT() stop the script from executing

This should only really be used when there is a fear of hack attack

Share this post


Link to post
Share on other sites
But you can do:
[code]<?php
if(!$_POST['uname'] | !$_POST['passwd']) {
echo('You did not fill in a required field.<br>');
include("footer.php");
die();
}
?>[/code]

Orio.

PS- nice av ;)

Share this post


Link to post
Share on other sites
Hi,

The easy solution to your problem is to use this:
[code]
<?php
if(!$_POST['uname'] | !$_POST['passwd']) {
echo 'You did not fill in a required field.<br>';
}
?>
[/code]

This won't stop the script, but it will tell you when the condition has failed.
Hope it works!
Iceman

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.