PHP MySQL Login Tutorial – Check if Username Exists




In another PHP MySQL login tutorial I’ll teach you how to check if the users username exists already before it’s created. This will stop multiple users from having the same username. All PHP…

Original source


40 responses to “PHP MySQL Login Tutorial – Check if Username Exists”

  1. how can we hide the database password?
    like in your tutorial u have declared '$password' as a parameter but its not initialized ….
    where is the value for the password ?
    Is there anyway that we can hide the password?

  2. 1) You don't hash your passwords,
    2) You don't sanitize the users input,
    3) You don't use prepared statements

    Why?? This isn't quite save. Never save a password as plaintext in your database and don't trust the users input. A hacker can insert malicious code and do whatever he likes. It becomes a lot harder to insert malicious code if you use prepared statements.

  3. How do i check if user ID exist or not ? Need help please. So far I did this

    public function isUserIDValid($user_id){

    return filter_var($user_id, FILTER_VALIDATE_REGEXP);
    but i'm getting "filter_var(): 'regexp' option missing" in and also invalid ID. How do I solve this problem ? TQ

  4. getting these ERRORS:

    Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/a5322190/public_html/phpscripts/signup.php on line 85

    Free Web Hosting

    PHP Error Message

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/a5322190/public_html/phpscripts/signup.php on line 86

  5. getting these errors:

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'a1636810'@'localhost' (using password: NO) in /home/a1636810/public_html/signup.php on line 48

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/a1636810/public_html/signup.php on line 48

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a1636810/public_html/signup.php on line 49

  6. There is no minimum or maximum password or username requirement.  This allows a user to "signup"  with nothing in the username and password boxes, which will then allow a user to "login" with nothing in the username and password boxes.

  7. Do NOT use any of the things this tutorial is giving you. He is providing concatenated data which is prone to SQL injections. Use PDO and not the deprecate mysql functions. With PDO, you have prepared statements which protect against SQL Injections.

  8. Thanks a bunch for this. I'm having some trouble though. On my website can simply enter anything you'd like into the login field and it will 'log you in.' How would I heck to see if the login, password and email match an entry in the database and deny the user access if they don't have an account? Maybe you already covered that and I just missed it.

Leave a Reply