Jump to content

Register System


WebKex

Recommended Posts

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 :/

Link to comment
https://forums.phpfreaks.com/topic/279718-register-system/
Share on other sites

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.