|
-
Jan 26th, 2008, 01:39 PM
#1
Thread Starter
Fanatic Member
How To Use include Function Safely ?
hi ,
How do you use include function safely to avoid anything relation about Injection....
& To design Your page do You use different page ?
i mean do you use single page That containe The header & the menu .. ?
or do you use different & you call in index.php using include function
-
Jan 26th, 2008, 03:14 PM
#2
Re: How To Use include Function Safely ?
The safe way to include the script is to hard code the name of it in your including script. This way, if the user tries to inject data or point it to a URL; it will be ignored and an error page displayed.
Also, disable URL fopens too. You should NEVER need it.
PHP Code:
$location = $_GET['location']; $include = '';
switch ($location) { case 'home': $include = 'contact.php';
case 'contact': $include = 'contact.php';
case 'admin': $include = 'admin.php';
default: // anything else the user entered $include = 'error.php'; }
include $include;
-
Jan 26th, 2008, 04:45 PM
#3
Thread Starter
Fanatic Member
Re: How To Use include Function Safely ?
Thanks m8
what about To design Your page do You use different page ?
i mean do you use single page That containe The header & the menu .. ?
or do you use different & you call in index.php using include function
-
Jan 26th, 2008, 06:09 PM
#4
Re: How To Use include Function Safely ?
No - there is no reason why the same code cannot on separate pages you have require (it's like include). It is best to separate each logical function of the site into separate pages; just as you separate each entity in a relational database into a table.
It will also make your site more search engine friendly as it will not see the query string (more likely to be dynamc data and will more likely follow it and crawl the page).
-
Jan 26th, 2008, 06:13 PM
#5
Thread Starter
Fanatic Member
Re: How To Use include Function Safely ?
-
Jan 26th, 2008, 06:19 PM
#6
Re: How To Use include Function Safely ?
A typical set of pages may look like this:
Code:
-- include
-- site.php
-- auth.php
-- htdocs
-- login.php
-- login_input.php
-- cart.php
-- cart_input.php
-- index.php
-- contact.php
-- contact_input.php
The site.php could be included and used to check authentication tokens and set up the / retrive the current state.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|