Search Results

Search found 2 results on 1 pages for 'jonnnnnnnnnie'.

Page 1/1 | 1 

  • Username correct, password incorrect?

    - by jonnnnnnnnnie
    In a login system, how can you tell if the user has entered the password incorrectly? Do you perform two SQL queries, one to find the username, and then one to find the username and matching (salted+hashed etc) password? I'm asking this because If the user entered the password incorrectly, I want to update the failed_login_attempts column I have. If you perform two queries wouldn't that increase overhead? If you did a query like this, how would you tell if the password entered was correct or not, or whether the username doesn't exist: SELECT * FROM author WHERE username = '$username' AND password = '$password' LIMIT 1 ( ^ NB: I'm keeping it simple, will use hash and salt, and will sanitize input in real one.) Something like this: $user = perform_Query() // get username and password? if ($user['username'] == $username && $user['password'] == $password) { return $user; } elseif($user['username'] == $username && $user['password'] !== $password) { // here the password doesn't match // update failed_login_attemps += 1 }

    Read the article

  • Variable wont echo

    - by jonnnnnnnnnie
    I have the following code, where the var $username doesn't echo, when you type in a value. //TODO: SET AUTH TOKEN as random hash, save in session $auth_token = rand(); if (isset($_POST['action']) && $_POST['action'] == 'Login') { $errors = array(); //USED TO BUILD UP ARRAY OF ERRORS WHICH ARE THEN ECHOED $username = $_POST['username']; if ($username = '') { $errors['username'] = 'Username is required'; } echo $username; // var_dump($username) returns string 0 } require_once 'login_form.html.php'; ?> login_form is this: <form method="POST" action=""> <input type="hidden" name="auth_token" value="<?php echo $auth_token ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password1"> <input type="submit" name="action" value="Login"> </form> The auth token part isn't important, it just when I type in a value in username textbox and press the login button, the username wont echo, var_dump returns string (0) and print_r is just blank.

    Read the article

1