Suggested articles for you:

68 thoughts on “PHP Login Form using MySQL

  1. blankAbiodun Awowole

    working with xampp environment, when the sign in form is click to sign in it shows my php code(” . $passwordError . “”; ?> ” . $noValid . “”; ?>) on below the enter password. And when i click on sign up it also show my php code on email box() and name box it shows (). kindly help. Thanks

    Reply
    1. blankRavi Bandakkanavar Post author

      Abiodun,

      Do you have access to the Database server? Could you please login and check whether the registered user details are present in the database?
      I hope you have configured the correct database user details in the connection file.

      Reply
  2. blankSarvesh

    Heyy!!!
    How to get the username, port of the mysql server.

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi
      By default, it will be root or no username in some cases. You need to set the username manually in such cases.
      For MySQL the default port is 3306. During installation, you get an option to update it even.
      You can check all the configuration details in conf file.

      Reply
  3. blankAditi

    Notice: Undefined variable: db in C:\xampp\htdocs\OPTRA\login.php on line 18

    Fatal error: Call to a member function prepare() on null in C:\xampp\htdocs\OPTRA\login.php on line 18

    Reply
    1. blankRavi

      Hi,

      Please check what name field are you using for “username” in LoginForm.php.

      Username:

      Reply
      1. blankZeyu

        Hi Ravi, I can’t read your full comments since it’s always loading. Could you send this comment to my email? I met the same issue.

        Reply
        1. blankRavi Bandakkanavar Post author

          Hi Zeyu,

          Are you seeing this error?

          Notice: Undefined variable: db in C:\xampp\htdocs\OPTRA\login.php on line 18

          Fatal error: Call to a member function prepare() on null in C:\xampp\htdocs\OPTRA\login.php on line 18

          It is something to do with the database query. You should verify whether the table is created and column names are correctly used in the query.

  4. blankWycliff

    Yes I created a table ‘PROFILE’ and insterted USERNAME as ‘wycliff’ and PASSWORD as ‘1234’ and I am runing it in a xampp environment. It still gives me the errors

    Reply
    1. blankRavi Bandakkanavar Post author

      In order to login to a system, you need to register the user first.
      Use the below links to do the user registration.
      https://krazytech.com/programs/php-mysql-registration-form
      https://krazytech.com/programs/complete-login-and-registration-application-using-php-and-mysql – Combined registration and login application.

      Also, the default MySQL setup of xampp has a username as ‘root’ and the password would be null. Either set the password for MySQL user or remove the password configuration in the DBConnection.php file.

      Reply
  5. blankWycliff

    I am getting this error when I try to log in.
    Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES) in C:\xampp\htdocs\DBConnection.php on line 11

    Fatal error: Uncaught Error: Call to a member function prepare() on boolean in C:\xampp\htdocs\Login.php:18 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Login.php on line 18

    kindly help

    Reply
    1. blankRavi Bandakkanavar Post author

      This is because of your MySQL credentials mismatch.
      Please set the username and password details in DBConnection.php as per your local MySQL setup.

      Reply
      1. blankZeyu

        Hi I met the same error, I’m using xampp software. Here is my DBConnection.php:

        Reply
    2. blanksanjay patil

      Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\essenet\login.php:18 Stack trace: #0 {main}thrown in C:\xampp\htdocs\essenet\login.php on line 18

      Reply
  6. blankCalvin Andrean

    Its still show me the incorrect password although i registered it to RegisterForm.php Can you help me?

    Reply

Did it help? Would you like to express?