I feel that the easiest and quickest way to achieve this is using a already built solution such as WordPress... but of course that doesn't allow for much learning, does it? :lol:
Still, your question is really wide. It involves:
- Creating the table and structure for the profile and user's data
- Using PHP code to open a connection to the database
- Creating specific forms (login, profile details or comments, depending on which are of the website you are)
- SQL queries to insert data, retrieve or modify it (like the profile, in case that they want to change something)
I'll use the example of the log in page. In this thread you'll find some interesting information as well as code examples. Do read it as there's a bit on discussion on best practices.
For the rest, I find that if you understand what it is said here, at least in general, you'll be able to code the other pages. The concepts are similar.
Now, if you don't know any PHP and you only want the code... this will be useless and even if you search the web for the code you need, you'll find yourself in trouble if you want to implement it (not imposible if the structure of your database matches the example but hard work)
In that case, I'd certainly advise you to use something like WordPress and the plugíns that you may need to create that functionality that you need... and then that you start to learn PHP