Jump to content

Preventing File from running through Address Bar


shreej21

Recommended Posts

In the file you want to prevent direct access, place something like in the header (meaning at the top, above your codes):

<?php

if (!defined("_IN_CODE")){
// display error message; user trying to get direct access. Something like:
echo "<b>404 - File Doesn't Exist.</b>";
}

// your codes here

?>

 

Then in the file you use include or require to call that page, you need to do something like:

<?php

define ("_IN_CODE", 1);
include "URL TO FILE";

// rest of codes here

?>

 

Understand?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.