Jump to content

[SOLVED] index.php names


light-angel

Recommended Posts

i have found this script

 

<?Php 

    // Define our array of allowed $_GET values

        $pass = array('main','ts','guides','news','hublist');

            

    // If the page is allowed, include it:

        if (in_array($_GET['page'], $pass)) {

            include ($_SERVER['DOCUMENT_ROOT'] . 'hubs/' . $_GET['page'] . '.php'); 

        } 

        

    // This will load the default page:

        elseif (!isset($_GET['page'])) {

            include ($_SERVER['DOCUMENT_ROOT'] . '/main.php'); 

        }



    // If the page is not allowed, send them to an error page:

        else {

                // This send the 404 header

                    header("HTTP/1.0 404 Not Found");

                // This includes the error page

                    include ($_SERVER['DOCUMENT_ROOT'] . '/error.php');

        }

?>

 

but when i put thin the link like www.mydomain.com/index.php?p=guides

i just keep getting up the main page and the others wont load can some one help me plz

Link to comment
https://forums.phpfreaks.com/topic/113075-solved-indexphp-names/
Share on other sites

why don't you just use..

if(!(isset($_GET['page']))){$P='';}else{$P=$_GET['page'];}

if($P=='guides')
{
echo("<META http-equiv='refresh' content='0;URL=http://www.mydomain.com/hubs/guides.php'>");
}

 

you could use a switch statement if you have alot of pages..

 

switch ($P)
{
guides:
  echo ("<META http-equiv='refresh' content='0;URL=http://www.mydomain.com/hubs/guides.php'>");
  break; //Stop leak into next case.
news:
  echo "Number 2";
  break;
ts:
  echo "Number 3";
  break;
main:
  echo "Number 4";
}

 

 

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.