![]() |
how to block a user from viewing a specific page
im wondering how i would be able to program this.
say i have pages that dont have anything on it but has backend code. how do i block people from typing that page into the url and view it? |
a) Don't put it in your document root. Have scripts call it from a different location.
b) If you have an Apache server, deny it with .htaccess or in your httpd.conf c) make sure the file extension is .php so that the code will be parsed and unviewable in the browser. d) put up a stop sign. e) password protect the directory (view .htpasswd or whatever your server uses) f) disable indexes. g) if you have a user authentication system and the script is an administration script of some sort, check for administrative authorization or kill the script if it's not found. It all depends on the specifics of what you're doing, and why you're doing it. -m |
PHP Code:
|
At the beginning of every file, put something like
PHP Code:
PHP Code:
|
i've been using...
Code:
//on index pageYou could do a header('Location: h*ttp://site.com/index.php instead of die() something i just thought of... writing a little script to log attempts to access restricted files. http_refferer, ip, time , etc... so you can see when, who... i'll post something about this later, cause i just had some crazy ideas heh |
on the top of my page i put
define('accesslevel', true); if(!accesslevel) { header("Location: index.php"); and i loaded the page and nothing happend. what am i missing (well obviously it wont work so what else do i need to put) |
Well, if those are both on the same page, then ACCESSLEVEL is true, and therefore the if statement doesn't execute.
Just a note for security purposes, if you want to make sure that nobody is going to view your page, you may want to add exit() or die() after the header() statement. Good ole lynx doesn't care about your header's if it doesn't want to. -m |
this worked for me
define('noaccess', false); if(!noaccess) { header("Location: login.php"); } |
PHP Code:
|
Also don't forget the
PHP Code:
|
| All times are GMT. The time now is 02:06 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0