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
Share on other sites

<?php $page = $_GET["page"];
if (!$page) {
include "/site/forum.php";
}
else if($page=="Forum" && $ID == 1)    {include "/site/whateverpageyouwant.php";}

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

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

Link to comment
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
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.