plznty Posted November 16, 2010 Share Posted November 16, 2010 // SESSION TEST if ($_SESSION['username']) { require_once("../mysql.php"); // Find Username from Session ID // Find Username from ID $finduser="SELECT username FROM users WHERE id='$_SESSION[username];'"; $finduserquery=mysql_query($finduser)or die(mysql_error()); $userfetch = mysql_fetch_array($finduserquery); // Set Username Variable $userfromid = $userfetch['username']; echo "lol" . ucwords($userfromid); } else { } Everytime I load this page more than once when logged in, it seems to turn the variable blank. Therefore making the user not be able to view other pages that use a session. Help? Thanks Quote Link to comment Share on other sites More sharing options...
revraz Posted November 16, 2010 Share Posted November 16, 2010 Where is session_start? Why dont you set a session variable saying they are logged in and then don't query the database again if so? Quote Link to comment Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 I have done, the login section works but if I visit this page something in what I have just shown changes the session['username'] variable. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 16, 2010 Share Posted November 16, 2010 Nothing in the code you pasted changes the session variable. Quote Link to comment Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 I cannot understand why its changing then. Confusing. Quote Link to comment Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 It apparently is okay without register_globals being on, but how can i do this without. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 16, 2010 Share Posted November 16, 2010 Why is register_globals on to begin with? Quote Link to comment Share on other sites More sharing options...
plznty Posted November 16, 2010 Author Share Posted November 16, 2010 Why is register_globals on to begin with? My web host provider has it on, what site do you get hosting off? I want to change, they have on outdated things such as magic quotes. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 16, 2010 Share Posted November 16, 2010 You can't use your own php.ini file with them? If you can, you can disable those things for your site. 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.