Reputation: 562
i wanted to store username of current logged in user
mysql_query(" UPDATE member SET url = 'ques2.php'
WHERE username = '$username' ") or die('Unable to update members URL: ' . mysql_error());
//in this i wanted to update my column url which is the last visited url of the logged in user i had used this to retireve my username
while($info = mysql_fetch_array( $data ))
{
//Print $info['username'] ;
if($info['username']==($fgmembersite->UserName('username')))
{
$username=$info['username'];
break;
}
}
but it is not retrieving the username of the logged in user AND I WANT TO STORE IT IN VARIBLE SO THAT I CAN RUN MY UPDATE QUERY....what is the problem in my code....please help.
Upvotes: 2
Views: 2202
Reputation: 3240
first page
session_start();
$_SESSION['userName'] = 'Root';
second page
session_start();
echo $_SESSION['userName'];
Upvotes: 1
Reputation: 382696
Store it in session:
$_SESSION['username'] = $info['username'];
Then on other pages, you can get it from that:
echo $_SESSION['username'];
Make sure to put session_start()
on top of every page where you use it.
Upvotes: 7