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

General Discussion

PHP backend for Admin?

Hi Randy,

Many thanks for your excellence Shirts 4 Mike tutorials.

But I wonder, I could not see the episode of how to setup the backend for Admin, like:

  1. Set up the passwords;
  2. Who can and or can not log in;
  3. The level of admin;
  4. Editor, like WYSIWYG;
  5. And other things that we need for a complete backend.

If there are none of those things in your tutorials, please make another tutorials about the backend.

I explored so many tutorials for PHP, and to me, your tutorials are THE BEST: they are simple, easy to understand, and applicable.

Best regards,

Nyoman Bali, Indonesia

2 Answers

Nyoman Bali,

There doesn't seem to be any videos that explain how to create the Admin portion of the site. You can apply the tutorials and knowledge that Team Treehouse offers for creating a PHP site that is database driven to do the following:

  1. At a high level, you would want to create a database table that will hold basic information for your users. For example, you may create a mysql database table called "users" with individual fields that hold the username, passwords, first name, last name, email, etc.
  2. You can either create a field in the "users" table to control certain admin rights. For example, you could create a field called "level" that can be used to store an arbitrary value of your choice to determine certain access on the site.
  3. You want to create a form that will post to a php page that that will $_GET the username and password posted in the form, run a query against your database "select username, password from users where username=post variable and password=post variable". There is a video on Team Treehouse that teaches you how to securely pass GET variables into a query. I don't want to write the code on the forum and teach bad practice. If there is a match in the database then you can take what is stored in the "level" field and set it to your session.
  4. Example of session. $_SESSION['level'] = "full-admin-rights"; . Through out your code, you will be able to write "If Statements" and conditions that say If($_SESSION['level'] == "full-admin-rights") then show whatever logic you want for those type of users.

If you haven't already, watch these videos: http://teamtreehouse.com/library/using-php-with-mysql

For more info on Sessions: http://www.php.net/manual/en/reserved.variables.session.php

For more info on Securing Variables in a form post to prevent sql injection: http://teamtreehouse.com/library/using-php-with-mysql/filtering-input-for-queries/understanding-sql-injections http://teamtreehouse.com/library/using-php-with-mysql/filtering-input-for-queries/preparing-sql-statements

For more info on securing passwords in your database, you want to encrypt passwords: http://www.php.net/manual/en/faq.passwords.php

Thanks Roselli for your quick respond.

Please consider my proposal. I am as your student, and other students as well, for sure really need those tutorials.

Bryan Lam
Bryan Lam
15,592 Points

I would also like to see an indepth tutorial on how to build a full administrative back end.