michaelpina Posted March 13, 2011 Share Posted March 13, 2011 Can someone help me understand why when I run this script I can see that {$_SESSION['user_level']} has changed for each user I login into for, but, for some reason the elseif statement never gets executed although I can see thru the debug line of i inserted (line 4: echo statement for user_level) does show that the 'user_level' variable does equals '1'? WHY? How come only the 'first_name" If statement executes and never the elseif? <?php // Changing Header Due to User Status // Add links if the user is an administrator: if ( isset($_SESSION['first_name'])) { echo 'Welcome user'; echo ", {$_SESSION['first_name']}!"; echo ", {$_SESSION['user_level']}!"; echo '<a href="../registration/login/logout.php" title="Logout"> | Logout</a> <a href="../registration/login/change_password.php" title="Change Your Password"> | Change Password</a> <a href="../addevent/" title="My Events"> | My Events</a> <a href="../addvenue/" title="My Places"> | My Places</a> <a href="../registration/login/register.php" title="Register for the Site"> | Register</a> <a href="../registration/login/forgot_password.php" title="Password Retrieval"> | Retrieve Password</a> '; } elseif ( isset($_SESSION['user_level']) == '1' ) { echo 'Welcome Admin'; echo ", {$_SESSION['first_name']}!"; // echo ", {$_SESSION['user_level']}!"; echo '<a href="../registration/login/logout.php" title="Logout"> | Logout</a> <a href="../registration/login/change_password.php" title="Change Your Password"> | Change Password</a> <a href="../addevent/" title="My Events"> | My Events</a> <a href="../addvenue/" title="My Places"> | My Places</a> <a href="../registration/login/register.php" title="Register for the Site"> | Register</a> <a href="../registration/login/forgot_password.php" title="Password Retrieval"> | Retrieve Password</a> '; echo '<a href="view_users.php" title="View Users"> | Users</a> <a href="../registration/login/view_activities_types.php" title="All Activity Choice Types"> | Activity Choices</a> <a href="../registration/login/admin/add_activity_type.php" title="Add Activity Choices"> | Add Activity Choices</a> '; } else { // echo ", {$_SESSION['user_level']}!"; } Link to comment https://forums.phpfreaks.com/topic/230497-isset-not-reading-variable/ Share on other sites More sharing options...
trq Posted March 13, 2011 Share Posted March 13, 2011 isset() will never return the string '1' Link to comment https://forums.phpfreaks.com/topic/230497-isset-not-reading-variable/#findComment-1186905 Share on other sites More sharing options...
redarrow Posted March 13, 2011 Share Posted March 13, 2011 <?php session_start();// <<< missing, there no session, if it not on every page, and written on every page. ?> Link to comment https://forums.phpfreaks.com/topic/230497-isset-not-reading-variable/#findComment-1186906 Share on other sites More sharing options...
michaelpina Posted March 14, 2011 Author Share Posted March 14, 2011 Sorry I hadn't placed my header ... here it is ... the idea sounded good until I actually revised the file this evening and saw that I have indeed initiated the session in an earlier part of the pages code. <?php # script 1.1 // This begins the HTML header status for the site. // Start output buffering: ob_start(); // Initialize a session: session_start(); // Check for a $page_title value: if (!isset($page_title)) { $page_title = 'User Registration'; } ?> Link to comment https://forums.phpfreaks.com/topic/230497-isset-not-reading-variable/#findComment-1187272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.