adamlacombe Posted September 25, 2010 Share Posted September 25, 2010 ok so I'll login to my account then once I'm logged in I visit a page with a: while(mysql_fetch_array($v)){ in it and it logs me in as someone else. if I remove the while it wont but I need to while. what do I do and whys it doing this? Login: <?php $title="Login"; $metakeywords="login, email"; $metadescription="Login to $sitename"; include("header.php"); if(!$_POST['submit']) { ?> <html> <div class="header">Login</div> <div class="content"> <form method="post" action="index.php?action=login"> Email:<br /> <input id="email" type="text" name="email" maxlength="16"> <br /> Password:<br /> <input type="password" name="password" maxlength="16"> <br /> <input type="submit" name="submit" value="Login"> </form> <a href="index.php?action=signup">Register Here</a> </div> </html> <?php } else { $user = protect($_POST['email']); $pass = protect($_POST['password']); if($user && $pass) { $pass = md5($pass); //compare the encrypted password $sql="SELECT id,email,password,activation_key FROM `users` WHERE `email`='$user' AND `password`='$pass'"; $query=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { $row = mysql_fetch_assoc($query); if($row['activation_key'] == 0){ $_SESSION['id'] = $row['id']; $_SESSION['email'] = $row['email']; $_SESSION['password'] = $row['password']; echo '<meta http-equiv="REFRESH" content="0;url=index.php">'; }else{ echo "<div class='error'>You need to activate your account first!</div>"; } } else { echo "<div class='error'>Email and password combination is incorrect!</div>"; } } else { echo "<div class='error'>You need to gimme a email AND password!</div>"; } } include("footer.php"); ?> code that logs me into another account: $sql2 = "select * FROM cheats WHERE game_id='$datas[id]'"; $rec2 = mysql_query($sql2) or die(mysql_error()); while($datas2=mysql_fetch_array($rec2)){ echo "<div class='header'>$datas2[title]</div>"; echo "<div class='content'>$datas2[cheat]</div><br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/214364-so-confused-why-this-is-happening-to-login/ Share on other sites More sharing options...
Pikachu2000 Posted September 25, 2010 Share Posted September 25, 2010 There doesn't appear to be a session_start(); in your login script. Quote Link to comment https://forums.phpfreaks.com/topic/214364-so-confused-why-this-is-happening-to-login/#findComment-1115537 Share on other sites More sharing options...
adamlacombe Posted September 25, 2010 Author Share Posted September 25, 2010 sorry, forgot to let you know that its in the index file along with the connect Quote Link to comment https://forums.phpfreaks.com/topic/214364-so-confused-why-this-is-happening-to-login/#findComment-1115538 Share on other sites More sharing options...
PFMaBiSmAd Posted September 25, 2010 Share Posted September 25, 2010 I doubt the posted code is ALL the relevant code that is being executed by or due to your while(){} loop code. The only ways that code execution could be causing the symptom is - 1) Your code is setting the $_SESSION variables directly. 2) Register_globals are on (they were turned off by default over 8 years ago) and you are setting a program variable that has the same name as one of your session variables. Edit: Another possibility is you have a header() redirect either in or affected by the while(){} loop code and you don't have an exit; statement after the redirect and some code after the header() is altering the $_SESSION variables. Quote Link to comment https://forums.phpfreaks.com/topic/214364-so-confused-why-this-is-happening-to-login/#findComment-1115540 Share on other sites More sharing options...
adamlacombe Posted September 25, 2010 Author Share Posted September 25, 2010 well every other page is fine until a while() comes a long so its not the header() or register_globals I wouldn't think. what do you mean by its setting it directly? Quote Link to comment https://forums.phpfreaks.com/topic/214364-so-confused-why-this-is-happening-to-login/#findComment-1115558 Share on other sites More sharing options...
adamlacombe Posted September 25, 2010 Author Share Posted September 25, 2010 I am so confused Quote Link to comment https://forums.phpfreaks.com/topic/214364-so-confused-why-this-is-happening-to-login/#findComment-1115564 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.