My login is messed up...
I have checked register and reguser and they work fine. They set all the correct information in the data base.
But it only lets me log in every few people I create; sometimes it works, sometimes it doesn't...
Example: I create a user called "pleasework" with a password of "pleasework". It lets me log in.
But then I created a user called "iamawizard" with a password of "wizard" and it won't let me log in.
So I thought it must have to have the same password as username so I made a user called "1234" with a password of "1234" and he couldn't lot in! Even if I go into the database and change the MD5 password to 1234, it won't let him log in..There is something really weird with my script or something.
This is my login and authenticate scripts..what can I do to make them work?
Code: Select all
login.php
<?php
include_once('phpinclude/connect.php');
include_once('phpinclude/logo.php');
?>
<div id="loginfalse">
<form method="POST" action="authenticate.php">
<table border='0' align="center">
<tr align="right"><td>User Name: </td><td><input type="text" name="player" size="21"></td></tr>
<tr align="right"><td>Password: </td><td><input type="password" name="password" size="21" mask="x"></td></tr>
<tr align="right"><td colspan='2'><input type="submit" value="Login" name="submit"></td></tr>
</table><br>
<br>
Not Registered? <a href='register.php' title='Register page'>Register</a><br>
<br>
<a href='index.php' title='Index'>Return to the index</a>.
</div>
Code: Select all
authenticate.php
<?php
include_once ('phpinclude/connect.php');
session_start();
include_once ('phpinclude/logo.php');
?>
<div id="loginfalse">
<?php
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and '$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='index.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>
</div> /*for the Login False ID*/