WebKex Posted June 30, 2013 Share Posted June 30, 2013 i get ''password doesn't match.'' when i register me on my site This is the PHP code: <?php mysql_connect("localhost", "root", "kingk980327rr") or die(mysql_error()); mysql_select_db("php") or die(mysql_error()); if(isset($_POST['login'])){ if(empty($_POST['username']) or empty($_POST['password'])){ echo "Fields cannot be left empty"; }else{ $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(sha1($_POST['password'])); $valid = mysql_query("SELECT * From users WHERE username='".$username."' and password='".$password."'"); if(mysql_num_rows($valid) == 1){ mysql_query("UPDATE Users SET online='1' WHERE username='".$username."'"); header("location: me.php"); }else{ echo "Password / username isn't correct."; } } } ?> <?php if(isset($_POST['register'])){ if(empty($_POST['rusername']) or empty($_POST['rpassword']) or empty($_POST['crpassword'])){ echo "Fields cannot be empty"; }else{ $do = mysql_query("SELECT * From users WHERE username='".mysql_real_escape_string($_POST['rusername'])."'"); if(mysql_num_rows($do) == 1){ echo "Users busy."; }else{ $rusername = mysql_real_escape_string($_POST['rusername']); $password = mysql_real_escape_string(sha1($_POST['rpassword'])); $rpassword = $_POST['rpassword']; if($password == $rpassword){ mysql_query("INSET INTO users (username, password) VALUES ('$rusername','$rpassword')"); echo "Account created."; }else{ echo "password doesn't match."; } } } } ?> and this is the html register form: <form method="post"> Användarnamn:<input type="text" placeholder="Ditt användarnamn" class="mywidth1" name="rusername"><br /> Lösenord:<input type="password" placeholder="Ditt lösenord" class="mywidth2" name="rpassword"><br /> Verifiera lösenord: <input type="password" placeholder="Skriv lösenordet igen" class="mywidth" name="crpassword"><br /> <input type="submit" class="regbutton" value="" name="register"> </form> And this is the HTML login form: <form method="post"> Användarnamn: <input type="text" placeholder="Namn" class="loginde" name="username"><br /> Lösenord: <input type="password" placeholder="Lösenord" class="loginde1" name="password"><br /> <input type="submit" class="login" value="" name="login"> </form><br /><br /> Hope someone can help me :/ Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 30, 2013 Share Posted June 30, 2013 First - echo out the two password values so you can see what they are. Quote Link to comment 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.