Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ckeck connection
- if (mysqli_connect_errno()){
- echo "1 connection failed"; // error code number 1 = connection failed
- exit();
- }
- $username = $_POST["name"];
- $password = $_POST["password"];
- $namecheckquery = "SELECT username, score, hash, salt FROM users WHERE username = '$username'";
- $namecheck = mysqli_query($con, $namecheckquery) or die("2: name check query failed"); // error code #2 = name check query failed
- var_dump($namecheck);
- if(mysqli_num_rows($namecheck) !=1)
- {
- echo "5: Either no user with name, more than one."; //error code number 5 number names does not match one
- exit();
- }
- // get login info from query
- $existinginfo=mysqli_fetch_assoc($namecheck);
- //$salt = $existinginfo["salt"];
- //$hash = $existinginfo["hash"];
- $salt = trim($existinginfo["salt"]);
- $hash = trim($existinginfo["hash"]);
- $loginhash = crypt($password, $salt);
- if ($hash != $loginhash)
- {
- echo "6: Incorrect password"; // error code number 6 password does not hash to match table
- exit();
- }
- echo "0/t" .$existinginfo["score"];
Add Comment
Please, Sign In to add comment