Jump to content

PHP check $_SESSION for real user


jamesxg1

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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.