Jump to content

session variable error


droidus

Recommended Posts

why is $loggedIn coming up as true, when the session user is never set?

 

      <?php
      if(isset($_SESSION['user'])) { 
  	$loggedIn = true; } else {
  	echo "<form id='login-form' action='' method='post'>
    <label for='login'>User ID</label><br />
	<input type='text' name='uname' id='uname' value=''.if (isset($login_errors)) {echo $_POST[uname].'' style='font-size:16px;' />
	<div class='clear' style='height:15px;'></div>
	<label for='password'>Password</label><br />
	<input name='pword' type='password' value=''.if (isset($login_errors)) {echo $_POST[pword].'' style='font-size:16px;' />
	<div class='clear' style='height:15px;'></div>
	<label for='remember_me' style='padding: 0;'>Remember me?</label>
	<input type='checkbox' id='remember_me' style='position: relative; top: 3px; margin: 0; ' name='remember_me' disabled='disabled'/>
	<div class='clear'></div>
	<input type='submit' class='button' name='login' value='Login' style='background-color:#FC0; font-weight:bold; padding:5px; border:none;' />	
  		</form>
	<div style='height:15px;'></div>
  	<div style='line-height:23px; font-size:12px;'>>> <a href='forgot.php' target='_blank'>Forget your User ID / Password? </a><br />
  		>><a href='admin_login.php' target='_blank'> Administrator Login</a>
  </div>";
  } 
  ?>
  <?php
  	if($loggedIn) {
	mysql_select_db($database_uploader, $uploader);    
	$query = "SELECT * FROM members WHERE uname='$_SESSION[user]'";
	$result = mysql_query($query) or die(mysql_error());

	if (mysql_num_rows($result) > 0) {
		$row = mysql_fetch_array($result) or die(mysql_error());

		$used = $row['bandwhitch'];

		$acntType = $row['acntType'];
		if ($acntType == 2) {
			$totalSpace = 500;
		}
		else {
			$totalSpace = 250;
		}
		$usagePercent = (round(($used/$totalSpace), 2)) * 100;
	}
}
echo "<a href='files.php'>My Files</a><br /><a href='my_account.php'>View your account details</a><br /><a href='upgrade.php'>Upgrade my account to Pro!</a><br /><a href='contact.php'>Technical Support</a><br /><a href='logout.php'>Logout</a><br />
<div id='outerPercentContainer' style='width: 200px; background-color:#FFF; border: 2px #000000 solid; margin-left:auto; margin-right:auto;'>
    <div id='actualPercentage' style='width: <?php echo $usagePercent; ?>%; background-color:#09F; font-weight:bold;'>
      <div id='percentageText' style='text-align:center; width:200px;'>  $usagePercent% of 250 MB </div>
      </div>
  </div>";
?>

Link to comment
Share on other sites

I'm going to guess you have some php code on your page before the code you posted that is setting $loggedIn or perhaps you have register_globals turned on and a post/get/cookie/session variable by that same name is causing $loggedIn to be set.

 

The code you posted is setting $loggedIn to true if the session variable is set, but is is not doing anything to $loggedIn if the session variable is not set, so any existing value $loggedIn has won't be affected if the session variable is not set.

 

What's all the code from the start of your page up through where you are testing if($loggedIn)? Also, what does a phpinfo() statement show for the register_globals setting and do you have any $_POST['loggedIn'], $_GET['loggedIn'], $_COOKIE['loggedIn'], or $_SESSION['loggedIn'] variables anywhere within your code?

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.