Jump to content

.php?page=Forum&ID=1


dezkit

Recommended Posts

is there a way i when i go to website.com/index.php?page=forum&ID=1 it goes to a different page then website.com/index.php?page=forum

 


<?php $page = $_GET["page"];
if (!$page) {
include "/site/forum.php";
}

else if($page=="Forum")       { include "/site/forum.php"; }

else { echo "<b><h1>404 Error</h1></b>"; } 
?>

Link to comment
https://forums.phpfreaks.com/topic/98385-phppageforumid1/
Share on other sites

That wont work friojole if register_gloabls is not enabled!

 

You'll be better of using:

<?php

if(isset($_GET['page']))
{
    switch($_GET['page'])
    {
        // url has ?page=forum
        case 'forum':
            // if url has the id present eg: ?page=forum&id=123
            // then include another page
            if(isset($_GET['id']) && is_numeric($_GET['page']))
            {
                include './site/whateverpageyouwant.php';
            }
            // url does not provide the id, just include forum.php
            else
            {
                include './site/forum.php';
            }
        break;

        // url has ?page=another_page
        // include another_page.php
        case 'another_page';
             include './another_page.php';
        break;

        // to add more more pages just do the same as above, eg:
        // url has ?page=one_more_page
        case 'one_more_page';
             include './one_more_page.php';
        break;

        // requested page is not found
        // display error
        default:
            die('<h1>404 Page not Found</h1>');
    }
}
// page var not present display error
else
{
    die('<h1>404 Page not Found</h1>');
}

?>

Link to comment
https://forums.phpfreaks.com/topic/98385-phppageforumid1/#findComment-503629
Share on other sites

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.