Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysqli_connect('localhost', 'admin', 'admin', 'carnival_db');
- //check that connection happened
- if (mysqli_connect_errno())
- {
- echo "1: Connection failed";
- exit();
- }
- $username = $_POST["name"];
- $password = $_POST["password"];
- //check if name exists
- $namecheckquery = "SELECT username, salt, hash, score, house FROM players WHERE username='".$username."';";
- $namecheck = mysqli_query($con, $namecheckquery) or die("2: Name check query failed");
- if(mysqli_num_rows($namecheck) != 1)
- {
- echo "5: Either no user with name or more than 1"; //error code #5
- }
- //get login info from query
- $existinginfo = mysqli_fetch_assoc($namecheck);
- $salt= $existinginfo["salt"];
- $hash= $existinginfo["hash"];
- $loginhash = crypt($password, $salt);
- if ($hash != $loginhash)
- {
- echo "6:invalid password";// Invalid credentials
- exit();
- }
- echo "0";
- echo "\t";
- echo $existinginfo["score"];
- echo "\t";
- echo $existinginfo["house"];
- ?>
Add Comment
Please, Sign In to add comment