A long time ago, I've made 2 tutorials pertaining to PHP Redirect problem, where the redirect is actually can be exploited when a user has done filling the form, then redirected to a page that contains information formnya it has been filled in correctly, and other information. But for this tutorial is different with 2 tutorials that I mentioned earlier. This tutorial discusses the php file more his own. What I mean here is direct access to a php file.
For example like this, you create a php file, where you do not want this php file it directly accessed through the URL, but want the php file can only be executed when the include by another file. And you display the warning "Forbidden"like this when the file is accessed directly.
How to do this? Please read this tutorial until the end.
We need at least 2 pieces of php files. The first is index.php in it is like this:
How to do this? Please read this tutorial until the end.
We need at least 2 pieces of php files. The first is index.php in it is like this:
[code] <br />
<? <br />
define (active, "yes"); <br />
require_once 'page.php'; <br />
?> <br />
[/ code]
Then the second is the page.php. And it is like this:
[code] <? <br />
if (active == "yes") {<br />
echo "i am inside"; <br />
} <br />
<br />
else {<br />
echo "You Can not Access this page ..."; <br />
} <br />
?> [/ code]
When we access the url index.php file via the browser, then what happens is, variables and functions in page.php file was on the run in the index.php file, this happens because the constant assistance that exist in index.php. While the appearance of "You Can not Access this page ..." is obtained when we directly access the url of the file page.php, this happens because constantnya does not exist or is not defined, so that there is "You Can not Access this page ...".
Good luck.
<? <br />
define (active, "yes"); <br />
require_once 'page.php'; <br />
?> <br />
[/ code]
Then the second is the page.php. And it is like this:
[code] <? <br />
if (active == "yes") {<br />
echo "i am inside"; <br />
} <br />
<br />
else {<br />
echo "You Can not Access this page ..."; <br />
} <br />
?> [/ code]
When we access the url index.php file via the browser, then what happens is, variables and functions in page.php file was on the run in the index.php file, this happens because the constant assistance that exist in index.php. While the appearance of "You Can not Access this page ..." is obtained when we directly access the url of the file page.php, this happens because constantnya does not exist or is not defined, so that there is "You Can not Access this page ...".
Good luck.
0 comments on Preventing Direct Access In PHP Files :
Post a Comment and Don't Spam!
Dont Spam please