Jump to content

So confused why this is happening to login


adamlacombe

Recommended Posts

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>";
}

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.