Wednesday, 15 May 2013

php - Setting a variable via the sessions once logged in -



php - Setting a variable via the sessions once logged in -

logging in of course of study have set $_session['username'] , $_session['password'] usual. trying pack variable utilize around site:

$logged = mysql_query("select * `users` `username`='$_session['username']' , password = '$_session['password']'"); $logged = mysql_fetch_array($logged);

one previous setups, has enabled me utilize $logged around site various reasons, such calling logged in users email echo in form,

however, time, when using method, fails echo anything. have tried using session username variable works echo username, tried using session echo email , didn't work.

if help me pinpoint why is, i'd grateful. doesn't seem pulling info user should.

for me seems escape-thing. try

$logged = mysql_query("select * users username='".$_session['username']."' , password = '".$_session['password']."'"); $logged = mysql_fetch_array($logged);

also create sure phone call session_start(); before sending headers/echoing if weren't aware.

off topic-tip

as long query isn't used in public, it's fine. if you're gonna utilize code anything, sure slash query variables. if not, , if credentials not validated nor hashed, nasty sql injection setting password '; delete * users;# query select * users username='johndoe' , password = ''; delete * users;#'

php mysql session variables

No comments:

Post a Comment