jamesxg1 Posted January 28, 2009 Share Posted January 28, 2009 I dont know if the title is rightly described, But i need some sort of PHP statment (Would probablly be a IF statment) that willl check the $_SESSION['username'] and match it to a page eg. if the user is on There profile it will show them a specific menu ?, How do i do this i have this so far <?php if(isset($_SESSION['username'])) { if($_SESSION['username'] == "$_SESSION['username']") { ?> Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/ Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 First of all, what do you pass to the script to let it know what users page is being viewed? Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-748820 Share on other sites More sharing options...
mapleleaf Posted January 28, 2009 Share Posted January 28, 2009 if(isset($_SESSION['u'])) { Select whatever is related to the the value of $_SESSION['u'] in your database and present it. Make sense? Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-748824 Share on other sites More sharing options...
jamesxg1 Posted January 28, 2009 Author Share Posted January 28, 2009 if(isset($_SESSION['u'])) { Select whatever is related to the the value of $_SESSION['u'] in your database and present it. Make sense? Hiya, I understand the $_SESSION part but whats the ['u'] for ? and nah i dont understand do u mean show the menu after this IF statment ? Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-748845 Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 First of all, what do you pass to the script to let it know what users page is being viewed? Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-748852 Share on other sites More sharing options...
jamesxg1 Posted January 28, 2009 Author Share Posted January 28, 2009 First of all, what do you pass to the script to let it know what users page is being viewed? i pass a $_GET['id'] if thats what you mean ? Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-748868 Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 OK then, You can use that $_GET['id'] to retrieve a username from the database. If the username from the database matches the username stored in session show some editing options, otherwise just show a standard profile page. Make sense? Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-748869 Share on other sites More sharing options...
mapleleaf Posted January 29, 2009 Share Posted January 29, 2009 I understand the $_SESSION part but whats the ['u'] for ? I use u instead of user_name. Lazy typer!! <?php if(isset($_SESSION['u'])) { $query = "SELECT whatever FROM table WHERE user_name = '{$_SESSION['u']}'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); echo $row['whatever'] ////etc etc being the fields in your database that you want }else{ echo 'No session set for you. Go login'; } ?> Link to comment https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/#findComment-749889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.