Well, I'm not sure if you wanted actual code or just an overview so I'll give an overview for now.
For each user file, you'll need to specify the user type: Admin, Employer, User
You will need to save their password information here as well along with any other data you wish to collect like an email address.
The password data saved should really be a hash of the actual password so that if someone manages to gain access to your database, they can't read the actual passwords.
To create a hash of the password, you simply modify the password with a hashing function or functions like MD5. Then when a user logs in, you run the same hash on the submitted password prior to comparing it to the stored password data.
Once the user logs in, your session data should be modified as such. It would be helpful to save the user type in the session data but not required.
For any page that is displayed, there are 4 diferent user types that might be able to view it or not. guest, user, Employer, and Admin.
All pages should be viewable by the Admin. You will need to check the users group type prior to displaying any page and prior to displaying any internal links on a page. You don't want to show the link to the admin control panel to guests do you?
So at the beginning of your page generation script, you should check the status of the users session and then their user type.
You'll assign their user type to a variable:
$usertype
then you'll check to see if that usertype is allow to view the information requested to be displayed.
For user only content:
CODE
if ($usertype == 'Admin' || $usertype == 'user') {
// Show content or link
}
For fully public content:
CODE
if ($usertype == 'Admin' || $usertype == 'user' || $usertype == 'Employer' || $usertype == 'guest') {
// Show content or link
}
Of course, you could skip the check altogether on this one! or just check to see if $usertype is assigned before displaying like this:
CODE
if ($usertype) {
// Show content or link
}
For logged in only content:
CODE
if ($usertype != 'guest') {
// Show content or link
}
This would be good for a log out link.
For guest only content:
CODE
if ($usertype == 'guest') {
// Show content or link
}
This would be good for a log in link.
If you use a database to store all of the information about what to display in which situation, then you can have each content item have it's own allowed user settings. But for the most part, you simply need to check for the usertype then determine if the content will be displayed or not as a result.
Since there are so many ways that this could be written, I don't want to get into much more detail without direct questions since my technic may differ from yours and my confuse you as a result.
Hope this helps.

vujsa
Reply