Jump to content


Photo

PHP Session


  • Please log in to reply
3 replies to this topic

#1 oscar123

oscar123
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 May 2006 - 12:11 PM

How do I filter results from a database based on which user is logged into the site?

I have got the session function working fine with basic user level matching but now want to run queries which check the Session Username with the 'employer' field in the cvs database. When they match I want them to be ommitted from the result.

"SELECT * FROM cvs WHERE employer != '$username'";

Is there another way of doing this? Maybe 'if' statements?

Please help - its driving me nuts!

#2 bbaker

bbaker
  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 02 May 2006 - 12:58 PM

you have to set the $username variable:

$username = $_SESSION['username'];

#3 oscar123

oscar123
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 May 2006 - 02:42 PM

Thanks so much - fantastic - it works!



[!--quoteo(post=370536:date=May 2 2006, 07:58 AM:name=bbaker)--][div class=\'quotetop\']QUOTE(bbaker @ May 2 2006, 07:58 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
you have to set the $username variable:

$username = $_SESSION['username'];
[/quote]


#4 ansarka

ansarka
  • Members
  • PipPipPip
  • Advanced Member
  • 128 posts
  • LocationCochin, Kerala, India

Posted 03 May 2006 - 12:21 PM

[!--quoteo(post=370560:date=May 2 2006, 09:42 AM:name=Richie455)--][div class=\'quotetop\']QUOTE(Richie455 @ May 2 2006, 09:42 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Thanks so much - fantastic - it works!
[/quote]


in php config file if you turned of global varibles you will have to use $_session['vaiablename']; to get the session registerd variable values

If the globalvaraible in turned on in php config file you can directly use the session variable
EVEN THE WORD IMPOSSIBLE IS SAYING I' M' POSSIBLE




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users