Page 1 of 1

Password Protection...

Posted: Tue Oct 07, 2003 10:32 pm
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

Posted: Wed Oct 08, 2003 5:09 pm
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.

Posted: Wed Oct 08, 2003 6:46 pm
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