Log in

View Full Version : [PHP] Displays the same error?



wsg14
16-11-2008, 10:42 PM
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$email = $_POST['email'];
$password = md5($password);

$query = mysql_query("SELECT * FROM `users`");
$data = mysql_num_rows($query);

if($grab_login === 1){
header("Location: index.php");
} else {
if($_GET['do'] == register){
if($data['username'] == $username){
echo "sorry mate, someone has that username already.";
}
if($password !== $cpassword){
echo "the two passwords do not match, learn how to type.";
} else {
$update = mysql_query("INSERT INTO `users` (`username`, `password`, `email`) VALUES ('".$username."', '".$password."', '".$email."')");
echo "congratulations, you signed up.";
echo "<meta HTTP-EQUIV=\"refresh\" CONTENT=\"5\"; URL=\"index.php\">";
}
} else {
echo "<form action=\"?do=register\" method=\"post\"><br />
username: <input type=\"text\" name=\"username\" /><br />
password: <input type=\"password\" name=\"password\" /><br />
confirm password: <input type=\"password\" name=\"cpassword\" /><br />
email: <input type=\"text\" name=\"email\" /><br />
<input type=\"submit\" value=\"login\" />
</form>";
}
}
?>

When I tested the script I got the error: "the passwords don't match, learn to type". I've tried it several times with the same password (copy + paste so they're not actually incorrect). I don't see anything wrong with it.

+rep

Trinity
16-11-2008, 10:54 PM
You've md5'd the first password, but not the second one.

wsg14
16-11-2008, 10:57 PM
Ahh, thanks.

Want to hide these adverts? Register an account for free!