Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Martin Murphy
Martin Murphy
19,321 Points

User Registration

Hi everyone,

So my latest project is going to take on some kind of user registration and I am not entirely sure the best way to go on this. Essentially it will start small so users can register to access content and that is about it. However in the future it could take on other features.

So my question is, do I develop this myself in php (or another language) or use a cms (wordpress, drupal etc). Interested to find out what ways others have done this when it comes to users. I think there are so many different ways to do it I just wanted to find the best way of going about this.

Thanks, Martin

3 Answers

I've built many user driven web applications and I've work with wordpress. But when not working with wordpress this is what I usually do.

1) Identify what data do I need from my users I.E First name, Last name, email, phone number etc

2) I design the database to hold the user info I want I.E a table with the columns id // unique ID for each user to identify them in other tables first_name last_name

And that's about it but just to continue a bit more

Lets take this simple example we are building a note taking web app with user logins

The info we will need for a USER might be - firstname, lastname, email, password So we create a database table to hold that information with a special column called "id" which will be unique to each user

It will look like this in a table:

id | first_name | last_name | email | password

1 | Daniel | Prince | example@example.com | 12345

2 | Christopher| Prince | example@example.com | 12345

Moving on now we will need to identify what info we need for a note That might be: id, user_id, title, body, date

Notice that their are two columns with ID in it the first column is to identify each row uniquely just like in the users table

But the second column is to say which user this note belongs.

The table would look like this

id | user_id | title | body | date

1 | 2 | First Post | This is the Body | 12/18/1996

2 | 1 | First Post | This is the Body | 12/18/1996

The first row belongs to the user with the ID number two and if we go to the users table and look for the ID number two we will see that it belongs to "Christopher Prince"

That's how you would map users to their own data.

Now you have what u need set. The user created the account now what? Well they will try to log in when they log in you'll need to see if their credentials match the ones in your database and if it does u signed them in and show information with that given ID

Konrad Pilch
Konrad Pilch
2,435 Points

What about the coding itself? Do you have some open source PHP or soemthing we could have look on how to code a login system?

Martin Murphy
Martin Murphy
19,321 Points

Thanks for the in depth post! See I have done this type of thing before however in the long run is this how people generally do it? In my experience I have used different cms' and coded myself but never had a standard. So basically I am wondering if building everything from the ground up would be a good option or is it unrealistic?

Konrad Pilch
Konrad Pilch
2,435 Points

Obeviously its realistic. But it would take a lot of time. Its good to do it like this to learn. You can better learn a framework and learn how to do this with it and then strap it.

Michael Hanna
Michael Hanna
17,649 Points

Hey Martin,

Carlos gave you a great PHP answer, and I agree with Konrad's advice: building it in PHP is a good way to learn.

I can't tell you definitively what the industry standard or recommended best practice is. I guess I would say it depends on your goals for (or the purpose of) this project.

Coding it yourself: good experience, you can create something very simple and streamlined, but if you want to grow it (add more features or complexity or ecommerce) you will encounter some limitations. If it's purely an educational project, this could be good—it will give you specific things to learn and develop your skills. But it could take a lot of time and energy at that point to learn what you need to.

Using WordPress: WordPress is big and a little clunky at times, but it's very expandable. Practically limitless. And multiple users is part of its core functionality. You can customize what different user types can see and access, etc. If you want to grow your project at all, I think WordPress gives you a lot more to work with.

I've spent a lot of time learning WordPress development (my PHP coursework on treehouse was mostly to give me a background for WordPress development). For me, there was a learning curve at the outset, but once I got the basics down I progressed pretty quickly.

Not sure how helpful this answer is, but I wanted to put in a plug for WordPress. :-)

Good luck with your project!

—Michael

Murat Hasdemir
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Murat Hasdemir
Front End Web Development Techdegree Graduate 20,968 Points

Martin its always depends on project some times using cms is good solution but some times its worse case scenario. I say this and most of programmers will disagree with this but its up to your clients preferences one of my client don't want me to use cms and and I say ok for it and write it on my own other one don't care as long as it works and I use drupal (which is better if on e-commerce sites but worse on personal ones).

For your project I prefer write my own login system it will take time but when needed I can add more tables to database to make more accurate changes in my system.