Suggested articles for you:

51 thoughts on “Complete Login and Registration Application using PHP and MySQL

  1. blankHuseyn

    Signing up for the same email for the second time does not generate an error “this email is already in use”. and re-register from the same post. how can we fix this?

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Huseyn,
      Could you please check in your database whether the email(username) that you are using is already present in your database?

      Reply
      1. blankHuseyn

        If there is a username, it gives an error. However, if the e-mail has been used, it does not give an error and is overwritten by the same e-mail.

        screen: https://prnt.sc/usufqd

        Reply
        1. blankRavi Bandakkanavar Post author

          That’s correct. It is working as per the logic. If you check our conditions, only the duplicate check is done for userName.

          / checking if a user already exists with the given username
          $sql = “select uidUsers from users where uidUsers=?;”;

  2. blanksanju

    Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘Email’@’localhost’ (using password: YES) in C:\xampp\htdocs\Complete-Login-and-Registration\includes\dbh.inc.php on line 8
    Connection failed: Access denied for user ‘Email’@’localhost’ (using password: YES)
    i got these kind of msg, my DB name are correct as in MYSQL.. What I need to do?

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Sanju,

      The username and passwords that you are using in the application are wrong.
      Try logging into MySQL console using the same username and password. Please validate your credentials.

      Reply
  3. blankMaxim

    Hello Ravi,
    Thank you for your code. It is one of the best of free codes of this kind on the Internet.
    Could you advise me on how user can add attachments to the sign-up form?

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Maxim,

      Thanks for the feedback. I am glad that it is helping you.
      The attachment part requires some extra coding so I am thinking of posting a new article on the same.

      Reply
  4. blankarisa

    hi, can i add different roles for user? for example i want to add admin and normal user. do i need to link to admin page after log in? and should i create another table in database which store admin’s information?

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Arisa,

      The role is decided at the time of registration. Either super admin decides the role or by default, everyone will have a common role, for example subscriber role. After logging in, each role will lead to a different interface (webpage).
      A common database is enough.

      Reply
  5. blankanand

    Warning: Use of undefined constant title – assumed ‘title’ (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\loginsystem\edit-profile.php on line 2

    Reply
  6. blankarisa

    hi, i try to delete “bio” element just to check whether it can function or not, apparently the data does not enter in database anymore once i delete any elements. can you tell me why?

    Reply
  7. blankarisa

    hi, i try to add “address” in the signup function but it always lead me to error. can you show me how to do it? and where i am supposed to edit

    Reply
    1. blankRavi Bandakkanavar Post author

      Add a new placeholder in form and you need to read the same key in PHP and store it into the database. Just follow any one of the existing elements of the form, you will get it.

      Reply
  8. blankcbabic

    Hi! I am trying to modify the signup.php by adding croppie.js image cropper to it. The problem is that croppie displays the final photo as base64 and thus it cannot be uploaded to the database. Any chance of adding a base 64 decoder to this application?

    Reply
      1. blankcbabic

        thank you for the response. However, I’m new to PHP and i don’t know how to do this the right way. Tried nearly all combinations of the decode without success :(

        Reply
      1. blankAnvesh

        Warning: mysqli_connect(): (HY000/1049): Unknown database ‘loginsystem’ in C:\wamp64\www\anvesh\includes\dbh.inc.php on line 8

        Reply
        1. blankRavi Bandakkanavar Post author

          Hi,

          Its failing at $conn = mysqli_connect($serverName, $dBUsername, $dBPassword, $dBName, 3306);
          Do verify your MySQL server’s credentials.

  9. blankYushiko

    Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES) in C:\xampp\htdocs\Complete-Login-and-Registration\includes\dbh.inc.php on line 8
    Connection failed: Access denied for user ‘root’@’localhost’ (using password: YES)

    what do i change in the code?

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Yushiko,

      What is the username and password for your MySQL application? You need to add the same details in the connection string.

      Reply
  10. blankrakshitha

    hi
    I am getting following error

    *website error. contact admint to have it fixed

    could you please help me

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Rakshitha,

      As you can see in the code, this error is thrown when SQL exception is raised. You have to verify the MySQL server’s credentials and database name. It should work after that.

      Reply
        1. blankRavi Bandakkanavar Post author

          Hi Saeed,

          What database server are you using? Can you provide the username and password used for your database server?

      1. blanksam

        hi i am too getting the same error after clicking submit on signup form. could u help me out here

        Reply
  11. blankFred

    Thanks for these great script. Bravo.
    I got the following error when i click on the edit profile button:

    Notice: Use of undefined constant TITLE – assumed ‘TITLE’ in C:\xampp\htdocs\loginsystem\edit-profile.php on line 2

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Fred,

      Sorry about that. Could you please try commenting the second line. The following line

      define(TITLE, “Edit Profile”);

      Reply
  12. blankDarryl Santmayor

    Hey im getting an error “Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: NO) in C:\xampp\htdocs\log\includes\dbh.inc.php on line 8
    Connection failed: Access denied for user ‘root’@’localhost’ (using password: NO)”

    I created loginsystem database but can u give the sql code for table creation.

    Reply
    1. blankRavi Bandakkanavar Post author

      Hi Darryl,

      Where are you executing this one?
      Please make the following change in dbh.inc.php and try.

      $dBPassword = “”; //Database password

      Reply
  13. blankDOHNA A S

    i want to download the complete project source code link please

    Reply
  14. blankRobert

    Hi Ravi,

    thanks for a nice tutorial! Regarding the registration process, can you add e-mail validation, i.e. the visitor needs to validate his/her e-mail (using a link with a token) before he/she can gain access?

    Reply
    1. blankRavi Bandakkanavar Post author

      Thanks Robert. You are proposing a good extension to the registration process. It needs a tweak in the table to include an additional column to track the email activations.
      I will either add it in the same process or try to write a separate post for the same.

      Reply
  15. blankRocky Edwards

    this is a very good tutorial but how could I make it where whoever logins has a personal page like background and other personal links to other pages based on their login credentials

    Reply
  16. blankt3ch_guru

    this is great but how can you add a personal page for the user login like if they have a custom background picture and links or icons on their personal page instead of everyone accessing the same index.php that shows nothing

    Reply
  17. blankcharles

    Thanks for the tutorial. I’m new to php; please kindly help me on how to link the files. Do I create several page templates for the “.inc.php” files?.

    Reply
      1. blankCharles

        Hello Ravi,
        Thanks for your prompt response to my last mail. But you haven’t uploaded the project zip as promised. There seems no download link to this tutorial. Please help…

        Reply

Did it help? Comment here..