Password Protection...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Password Protection...

Post by Mr. Tech »

Hi!

I am making a content management system that uses mysql.

When they go to view a page, it looks like this:

index.php?page=Home
index.php?page=Home/Search
index.php?page=Home/Search/About


And in the mysql database, it looks like this:

id :: path :: title :: password :: passwords

1 :: 1 :: Home :: Yes :: password1, password2
2 :: 1/2 :: Search :: No ::
3 :: 1/2/3 :: About :: No ::


Now Search is a subcategory to Home and About is a sub-subcategory to Home. Understand?

Now, I want to make home password protected which is easy because I just put Yes in password and them add the passwords. Then I just write a simple script that makes sure users login before viewing.

But what my problem is, is making the sub categories of Home password protected aswell, using the same passwords as Home without having to go in and add the passwords manually.

Understand? How can I do this?

Thanks,

Ben
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Kind of hard to make a suggestion without really knowing how you are logging them on. My guess would be to make a PHP file that makes sure they are logged in whether you are using sessions or cookies. Then just include(login.php) at the top of all the pages. I don't know if this would work or not depending on how you have implemented it.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

The passwords shouldn't really be stored in the table: instead create a passwords table as well as a join table defining a many-to-many relationship:
http://www.oreilly.de/catalog/javadtabp ... r/ch02.pdf

Modified pre-order tree traversal might possibly be useful:
http://www.sitepoint.com/article/1105/1
Post Reply