How to create Users using PHP and MySQL?

Hello, I would like to create a system where there will be 1 super admin, 5 admins and then numerous normal users.

Let’s say a School Principal, Teachers and then Students.

Can some kind soul give me a a general idea or links to on how shall I start?

Thank you.

First, design the database layout - what fields are required, how many tables you need, and so on. Only when you are sure of that, start writing code. And be prepared to change the database layout once you get started.

How much HTML and PHP experience do you have?

1 Like

Thanks DS. OK… well I have 5+ exp. in HTML, CSS and graphic design. I am trying to acquire new skills like JS, JQuery and PHP, MySQL. Very new to these programming skills. Still stuck at basics.

OK, then break it down into steps. Firstly, what’s the system going to be used for? That is, is it a database of students and teachers and so on, so you can search, list, link to classes and so on. Or is it to have a login system which gives different privileges according to what type of user they are?

I’d say the first thing to do after you’ve designed and created the database and its tables is to manually create a couple of users, then write yourself a login screen, presuming that the point of this is something your users can log in to. You can do the form itself as you know HTML. Then you need to write the PHP script that takes the details from the login screen and go from there:

  • Get the form variables and just display them
  • When that works, stop displaying them and instead connect to your database
  • Retrieve all your users and display them
  • Refine the query to only retrieve the user you need, based on the form data
  • Change the code to check the password is correct
  • Do something if it is, and something if it is not

How you go from there depends on what your system needs to do, but it will show how to pass form variables, how to run queries, how to react depending on the outcome of those queries, which I’d say is a reasonable grounding.

I’d say forget about jquery / Ajax and so on until you have the basic form processing working. Then you can add the bells and whistles. And make sure you use the latest PHP coding standards - use PDO (in my opinion) for the database connection, don’t bother with the old-style mysql calls - apart from anything else you’ll never hear the last of it if you post your code on here and it uses them. A lot of tutorials are old, so if you find one that uses something like

mysql_query("SELECT * FROM table");

then drop it and find a more modern one.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.