Jump to content

Recommended Posts

Hey everyone, how would I get the word TEST to show correctly?  I am trying to pass my user level into the menu. 

 

<?php 
	if ($_SESSION['userLevel'] > 2) {
	die();

	echo "<li><a href=\"#\">TEST</a></li>"; }  ?>

 

<?php 

$mode="mode22";
if(isset($_POST['mode'])) {  
$mode = $_POST['mode']; 
}
if(isset($_GET['mode'])) {
$mode = $_GET['mode'];
}

switch ($mode) {

case 'login':    

$username = $_POST['login'];     
$password = $_POST['password'];


include ('db_fns.php');

	if (!connector())
	{
		die ('connection dies');    
	}

	if (loginCheck($username, $password)) 
	{
		header('location: loggedin.php');
	}

	else 
	{
		die ('login has failed <a href="login.html">Click here to login again</a>'); 
	}

break;

case 'adduser': 

if ($_SESSION['userLevel'] < 2) {
	die('access denied');
}

	$username = $_REQUEST['userName'];  
	$password = $_REQUEST['passWord'];  
	$firstName = $_POST['firstName'];  
	$lastName = $_POST['lastName'];  
	$department = $_POST['department'];  
	$userLevel = $_POST['userLevel'];  


	if (empty($username) || empty($password)){

        echo "please enter a username.";

	die;

	}






	//print_r($_POST); 

	include ('db_fns.php');

	if (!connector())
	{
		die ('connection dies');    
	}

	if(!addUser($username,$password,$firstName,$lastName,$department,$userLevel)) 
	{
		die('There was a problem - contact the system administrator');
	}
	else
	{
		echo "Data has been submitted. <a href=\"/IOM/admin\">return to administration</a>";
	}

	break;

		default:

		break;
				}



?>

Link to comment
https://forums.phpfreaks.com/topic/178087-if-statement-question/
Share on other sites

if ($_SESSION['userLevel'] > 2) {

	echo "<li><a href=\"#\">TEST</a></li>";
                       die();
}  ?>

 

the problem was you were stopping the program via die the echo statement. die kills the program so the echo statement was never executed

so when you are saying it is dying now, do you mean that TEST is still not displaying, even though you moved it below the echo? That means your condition is not evaluating true.  do you have session_start(); somewhere before that condition? If so, echo out your session var, does it hold what you expect (and it is higher than 2)?

so when you are saying it is dying now, do you mean that TEST is still not displaying, even though you moved it below the echo? That means your condition is not evaluating true.  do you have session_start(); somewhere before that condition? If so, echo out your session var, does it hold what you expect (and it is higher than 2)?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.