Jump to content

ID Linking


Bavilo

Recommended Posts

Ok,

I am really frustrated right now...This has been going on for several weeks now and i just cannot find an answer. I have one index.php where i have the following code

[code]
<?
        $val = $_GET['id'];
        $val .= ".php";
        $dirty = array("..");
        $clean = array("");
        $val = str_replace($dirty, $clean, $val);

        if (isset($_GET['id'])) {
        if (file_exists($val)) {
        include "$val";
        }
          else {
                include "id/404.php";
               }
       }
          else {
                include "id/start.php";
       }
    ?>
[/code]

I use this to navigate from page to page without having to make a complete new page for everything. So this basically just includes another page with the php extension into my main div. This works great for pages that do nothing but hold content. But it will not work if i try to link to a gallery or slideshow, or whatever, that has to include other pages. Once i include for example gallery.php, the gallery.php is now part of my index.php in the main div. It has no way of including all the other pages as its in the wrong directory. And i can't just go into the gallery.php and change every single link because it doesn't seem to work in this format. index.php?id=id/gallery/ I dont know what to do. How does everybody else pull this off??

Thanks in advance
Mike
Link to comment
Share on other sites

In your included files, for example gallery.php, make sure that you have the full path to the file to be included from gallery.php. Meaning use:

[code]include("/includes/somefile.php");[/code]

not just:

[code]include("includes/somefile.php");[/code]

You shouldn't have to put the full path to the file from the file system (/usr/username/... or c:\www\files\includes...) just from the document root should be fine.
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.