Jump to content

php help?


dezkit

Recommended Posts

How do i make so there is like &type=1234 after the

$page=="home"

 

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

else if($page=="home")       { include "/site/home.php"; }
else if($page=="events")     { include "/site/events.php"; }
else if($page=="employment") { include "/site/employment.php"; }
else if($page=="gallery")    { include "/site/gallery.php"; }
else if($page=="links")      { include "/site/links.php"; }
else if($page=="djs")        { include "/site/djs.php"; }
else if($page=="vip")        { include "/site/vip.php"; }
else if($page=="forum")      { include "/site/forum.php"; }
else if($page=="contact")    { include "/site/contact.php"; }
else { echo "<b><h1>404 Error</h1></b>"; } 
?> 

 

Link to comment
Share on other sites

You wouldn't need to, if I understand what you're trying to do correctly.

 

Just set the &type=1234 bit to a variable, and then you will be able to use it in any script you include.

 

<?php

$page = $_GET["page"];
$type = $_GET["type"];

if(!$page) {include "/site/home.php"; }
else if($page=="home")       { include "/site/home.php"; }
else if($page=="events")     { include "/site/events.php"; }
else if($page=="employment") { include "/site/employment.php"; }
else if($page=="gallery")    { include "/site/gallery.php"; }
else if($page=="links")      { include "/site/links.php"; }
else if($page=="djs")        { include "/site/djs.php"; }
else if($page=="vip")        { include "/site/vip.php"; }
else if($page=="forum")      { include "/site/forum.php"; }
else if($page=="contact")    { include "/site/contact.php"; }
else { echo "<b><h1>404 Error</h1></b>"; } 
?>

 

So any page you include through your if statement will be able to use the $type variable.  There is no need to pass it through the URL of the include function.

 

Theo

Link to comment
Share on other sites

in home.php just check to see if the postID variable exists, if it does display what you want,

<?php

// see if postID url parameter exists and holds a number
if(isset($_GET['postID']) && is_numeric($_GET['postID']))
{
    echo 'Display Something else<br />postID: ' . $_GET['postID'];
}
else
{
    echo 'Display Homepage';
}

?>

 

Also I'd use a switch/case rather than an if/elseif/else statement for displaying the page:

<?php

if(isset($_GET['page']) && !empty($_GET['page']))
{
    $page = $_GET['page'];

    switch($page)
    {
        case 'home':
        case 'events':
        case 'employment':
        case 'gallery':
        case 'links':
        case 'djs':
        case 'vip':
        case 'forum':
        case 'contact':
            include './site/' . $page . '.php';
        break;

        default:
            die('404 Error - Page does not exist');

    }
}
else
{
    die('404 Error - Page does not exist');
}

?>

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.