My problem is, it seems to be encrypting the password when i register a name, and i dont remember putting md5 into the registration script. and its not letting me login, even when i use the encrypted password from the database, also, it seems to log me in no matter what password i enter
Heres my login script
login.php:
<?
setcookie("username", $username);
setcookie("passwd", $passwd);
$dbuser = '****';
$dbpass = '****';
//connect to the DB and select the database
$connection = mysql_connect('localhost', $dbuser, $dbpass) or die(mysql_error());
mysql_select_db('Hazardnet', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM HN_users
WHERE username='$username' and passwd='$passwd'";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
print "Thank your for logging in, $username, Please continue into the <a href=\"members.php\">members area</a>";
}
else{
print 'Sorry, you seem to have entered an incorrect Username/Password.';
}
?>
Heres my registration script
register.php:
<?
$db = mysql_connect("localhost","****","****");
mysql_select_db ("Hazardnet");
if($username=="" || $passwd=="" || $email=="")
{
echo "Please fill out all fields.";
}
else
{
$check_query = "SELECT * from HN_users WHERE username = '$username'";
$result = mysql_query($check_query);
if(mysql_num_rows($result)!=0)
{
echo "$username is already taken, sorry, please try again.";
}
else
{
$insert_query = "INSERT INTO HN_users (username, passwd, email)VALUES ('$username', '$passwd', '$email')";
$result = mysql_query ($insert_query);
if(mysql_error())
{
echo "there was a problem";
}
else
{
echo "Thank you for registering with HazardNet Computers! you may now login $username.";
}
}
}
mysql_close($db);
?>
and heres just my login table html
user_login.php:
<table align="center" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<form action="login/login.php" method="post">
<font size="-2">User:</font><br />
<input size="20" type="text" name="username" class=login>
</td>
</tr>
<tr>
<td>
<font size="-2">Password:</font><br />
<input size="20" type="password" name="passwd" class=login>
</td>
</tr>
<tr>
<td align="right" valign="baseline">
<font size="-1"><a href="?HNC=register">Register</a></font>
<input type="submit" value="" style="border:0;width:60px;height:15;background-image:url('login\login.jpg')">
</form>
</td>
</tr>
</table>