68 thoughts on “PHP Login Form using MySQL”

  1. Hello Sir
    I am getting error as Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES) in C:\xampp\htdocs\essenet\dbconnection.php on line 7 while trying to login using registered credential in mysql, please suggest

  2. blank
    Abiodun 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

    1. 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.

    1. 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.

  3. 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

      1. 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.

        1. 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. 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

    1. 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.

  5. 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

    1. 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

Did it help? Would you like to express?

%d bloggers like this: