voloproductions Posted October 18, 2009 Share Posted October 18, 2009 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 More sharing options...
mikesta707 Posted October 18, 2009 Share Posted October 18, 2009 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 Link to comment https://forums.phpfreaks.com/topic/178087-if-statement-question/#findComment-939017 Share on other sites More sharing options...
voloproductions Posted October 18, 2009 Author Share Posted October 18, 2009 with the below code it is dieing.... it should be passing? <?php if ($_SESSION['userLevel'] > 2) { echo "<li><a href=\"#\">TEST</a></li>"; } die(); ?> Link to comment https://forums.phpfreaks.com/topic/178087-if-statement-question/#findComment-939020 Share on other sites More sharing options...
mikesta707 Posted October 18, 2009 Share Posted October 18, 2009 if you don't want your program to stop executing at that spot, than remove the die(); Link to comment https://forums.phpfreaks.com/topic/178087-if-statement-question/#findComment-939022 Share on other sites More sharing options...
.josh Posted October 18, 2009 Share Posted October 18, 2009 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)? Link to comment https://forums.phpfreaks.com/topic/178087-if-statement-question/#findComment-939023 Share on other sites More sharing options...
voloproductions Posted October 18, 2009 Author Share Posted October 18, 2009 well my problem is I cant get test to show.... can you aim me? volonetmatt Link to comment https://forums.phpfreaks.com/topic/178087-if-statement-question/#findComment-939024 Share on other sites More sharing options...
.josh Posted October 18, 2009 Share Posted October 18, 2009 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)? Link to comment https://forums.phpfreaks.com/topic/178087-if-statement-question/#findComment-939026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.