dacoder96
02-01-2010, 11:11 AM
Hello, thanks for opening the thread!
I'm making a blog site and I need to be able to authenticate the pages.
This is the second or maybe even third time I have written this post because it's pretty confusing...
My blog contains 3 main files when loading a page.
globalHeader.php - this page has all the SQL stuff and variables etc...
the content page (eg: index.php) - this page contains the content and has globalHeader and globalFooter INCLUDED in it using the include function
globalFooter.php - this page closes everything up to make it work
I need some pages to be authenicated and only certain user groups can view them.
Here are the user groups;
0 - guest
1 - admin
2 - mod
3 - user
I need a script that can authenticate each page to more then one user group (eg; Admin Control Panel can be viewed by Mod and Admin eg2; member profiles can be viewed by admin, mod, user)
So far I have this...
if($_SESSION['blogUsername'] != 'guest' && $_SESSION['blogAccess'] = '1' && $_SESSION['blogGroup'] = $pageView) {
echo"nice";
}
else {
echo"oh no!";
}
How it works...
It checks if blogUsername is not equal to guest,
if blogAccess is equal to 1 (meaning they have logged in),
if $pageView is equal to blogGroup
Explanation...
- all session variables are in the globalHeader all set, ready to go!
- $pageView will be on every single CONTENT page BUT the script is above it in the globalHeader (so that I don't need to insert it into every page) but that means; if the variable is under the script it doesn't apply because the server reads it top to bottom. So if the variable is below the checking IF statement it wont exist.
If you can help me fix it somehow and get it to work or completely make a new one that's really helpful!
Just make sure multiple user groups can view pages depending on my choice.
--
Later on I might have to add these variables to a database so that I can change who can view which page from a control panel without having to change all the coding but this is just a basic site and it is my first time to use so much PHP so I'm having just a little trouble.
Thanks for viewing the thread and reading it. I hope it wasn't to confusing because my first one I wrote was really over the place!
:thumbsup:
I'm making a blog site and I need to be able to authenticate the pages.
This is the second or maybe even third time I have written this post because it's pretty confusing...
My blog contains 3 main files when loading a page.
globalHeader.php - this page has all the SQL stuff and variables etc...
the content page (eg: index.php) - this page contains the content and has globalHeader and globalFooter INCLUDED in it using the include function
globalFooter.php - this page closes everything up to make it work
I need some pages to be authenicated and only certain user groups can view them.
Here are the user groups;
0 - guest
1 - admin
2 - mod
3 - user
I need a script that can authenticate each page to more then one user group (eg; Admin Control Panel can be viewed by Mod and Admin eg2; member profiles can be viewed by admin, mod, user)
So far I have this...
if($_SESSION['blogUsername'] != 'guest' && $_SESSION['blogAccess'] = '1' && $_SESSION['blogGroup'] = $pageView) {
echo"nice";
}
else {
echo"oh no!";
}
How it works...
It checks if blogUsername is not equal to guest,
if blogAccess is equal to 1 (meaning they have logged in),
if $pageView is equal to blogGroup
Explanation...
- all session variables are in the globalHeader all set, ready to go!
- $pageView will be on every single CONTENT page BUT the script is above it in the globalHeader (so that I don't need to insert it into every page) but that means; if the variable is under the script it doesn't apply because the server reads it top to bottom. So if the variable is below the checking IF statement it wont exist.
If you can help me fix it somehow and get it to work or completely make a new one that's really helpful!
Just make sure multiple user groups can view pages depending on my choice.
--
Later on I might have to add these variables to a database so that I can change who can view which page from a control panel without having to change all the coding but this is just a basic site and it is my first time to use so much PHP so I'm having just a little trouble.
Thanks for viewing the thread and reading it. I hope it wasn't to confusing because my first one I wrote was really over the place!
:thumbsup: