i have a website where i am going to create a demo acct. I want to restrict the access for that demo acct "user" to pages such as changepassword.php
please help. thanks in advance
Restrict Access
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Restrict Access
Typically you would store some information in the session, a cookie, or the user's database record that protected pages would check for (and require to be set correctly) before the page would display.
(#10850)
Re: Restrict Access
It might not be the best, but here is what I use to restrict access to administrator only pages and then redirect to a neutral page where a message will displayed informing them of what they have done and a warning if they continue. The $_SESSION variable is declared and assigned its value at login and that information come from their profile in the database, so unless they login as an administrator they should not have access to the pages in question. Hope this helps and if you find a more efficient example, please share it with the rest of us.
Code: Select all
public function checkAdministratorAccess( ){
if($_SESSION["ADMINISTRATOR"] != "yes"){
# your code here...
header("Location: http://www.yourpagehere.com");
}
}
Code: Select all
$userAccess = UserAccess::getInstance( );
$userAccess -> checkAdministratorAccess( );
Re: Restrict Access
is there the possibility to set up something along the lines of
if user id = "x" then show error code "you have no access to this page"
if user id = "x" then show error code "you have no access to this page"
-
Peter Kelly
- Forum Contributor
- Posts: 143
- Joined: Fri Jan 14, 2011 5:33 pm
- Location: England
- Contact:
Re: Restrict Access
If you follow a user system like in the tutorial I have created at
http://www.peter-kelly.com/website-deve ... em-part-1/ and http://www.peter-kelly.com/website-deve ... em-part-2/
I have included ways that you can limit access per account or if there not logged in. If you have a look at that you should be able to see how I have done this and take example from this.
http://www.peter-kelly.com/website-deve ... em-part-1/ and http://www.peter-kelly.com/website-deve ... em-part-2/
I have included ways that you can limit access per account or if there not logged in. If you have a look at that you should be able to see how I have done this and take example from this.