Jump to content

Need help FAST.


Kynetek

Recommended Posts

Ok. I know what I need is something simple, but I just can't remember exactly what the code for it is.

 

Basically I have a file, my .php file. But what I want to do is make an include that allows me to click a link and it'll include it into the main content table of the page...

 

All I can really remember is that the URL I used to use looked something like this:

 

http://http://free.hostultra.com/~kynetek/index2.php?id=News/News.html

 

If someone could help me i'd be godly greatful...

Link to comment
Share on other sites

$page = $_GET['id'];
include("$page");

Ted

That is extremely insecure!

 

I would do something like this:

if(isset($_GET['id']))
{
    $page = $_SERVER['DOCUMENT_ROOT'] . '/' . $_GET['id'];

    if(file_exists($page))
    {
        include "$page";
    }
    else
    {
        die($page . ' cannot be found!');
    }
}

That is much more secure.

Link to comment
Share on other sites

 

That is extremely insecure!

 

I would do something like this:

if(isset($_GET['id']))
{
    $page = $_SERVER['DOCUMENT_ROOT'] . '/' . $_GET['id'];

    if(file_exists($page))
    {
        include "$page";
    }
    else
    {
        die($page . ' cannot be found!');
    }
}

That is much more secure.

 

errr..... 

 

url.php?id=../../../somefile.php

 

You'd be far better off cleansing that variable prior to using it. eg. intval($_GET['id']) or at least stripping out any ".." from it.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.