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']") { ?> Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 ? Quote Link to comment 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? Quote Link to comment 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 ? Quote Link to comment 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? Quote Link to comment 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'; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.