Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once('connect.php');
- {
- $uname = strip_tags($_POST['username']);
- $upass = $_POST['password'];
- if ( empty($uname) ) {
- $errors[] = "Username can't be empty";
- } elseif ( strlen($uname) > 64 or strlen($uname) < 5 ) {
- $errors[] = "Username must be longer than 5 characters and shorter than 64";
- } elseif( empty($upass) ) {
- $errors[] = "Please enter a password";
- } elseif ( strlen($upass) < 6 ) {
- $errors[] = "Password has a minimum length of 6 characters";
- } else {
- $query = "SELECT username, pass FROM users WHERE username=?";
- $stmt = mysqli_prepare($dbconnect, $query);
- mysqli_stmt_bind_param($stmt, "s", $uname);
- mysqli_stmt_execute($stmt);
- mysqli_stmt_store_result($stmt);
- if (mysqli_stmt_num_rows($stmt) == 1) {
- mysqli_stmt_bind_result($stmt, $db_uname, $db_pass);
- mysqli_stmt_fetch($stmt);
- if (password_verify($upass, $db_pass)) {
- echo "Success";
- } else {
- echo "Wrong username or password";
- }
- } else {
- echo "No user found";
- }
- }
- if(!empty($errors)) {
- foreach( $errors as $error ) {
- echo $error;
- }
- }
- $hashed_pass = password_hash($upass1, PASSWORD_DEFAULT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement