Jump to content


Photo

PHP DIE Function


  • Please log in to reply
3 replies to this topic

#1 chris_davidsonuk

chris_davidsonuk
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 26 August 2006 - 10:38 AM

I am using login script I found at http://www.free2code...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.

	if(!$_POST['uname'] | !$_POST['passwd']) {
	
		die('You did not fill in a required field.<br>');
		
	}

Is there anyway to include my footer file (footer.php) even if the script has 'DIED' ?
---------------------------------------
[a href="http://www.studioeight.net" target="_blank"]www.studioeight.net[/a]

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 26 August 2006 - 10:58 AM

no
DIE() and EXIT() stop the script from executing

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

Tell me the problem, I will try tell you the solution

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 August 2006 - 11:02 AM

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

Orio.

PS- nice av ;)
Think you're smarty?

(Gone until 20 to November)

#4 Iceman512

Iceman512
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 26 August 2006 - 11:03 AM

Hi,

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

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users