Jump to content

Recommended Posts

I don't know if it matters but the method I have opted for is a url like:

index.php?id=help

 

Then I created a script that I include in my template that looks like this:

 

<?php
// Check if first visit
if ($_GET['id'] == "") {
	header("Location: http://www.mydomain.com/index.php?id=main");
}


// Determine Tool to load
$pg2Load = $_GET['id'];

// Load Main Site Page
$filename = '/home/nxsap/www/pg_'.$pg2Load.'.php';

if (file_exists($filename)) {
    $pgID = "pg_".$pg2Load.'.php'; 
    } else {
    header("Location: http://www.mydomain.com/index.php?id=main");
}
    
?>

 

With this method there is no need to include the PHP extention. Basically as your site grows you simply name the new page pg_PAGENAME.php and there is no need to worrying telling a script what the new page name is.

 

 

Link to comment
https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576695
Share on other sites

This is what you want. This select statement will take the value in page and if it finds that value in the switch statement, display the approrpriate page. If however the value in page is not in the list or is empty it will the run the default section which displays the homepage.

 

switch(strtolower($_GET['page']))
{
case "news":
    include("/homepage/news/news.html");
break;
case "contact":
    include("/homepage/contact/contact.html");
break;
default:
    include("/home.php");
break;
}

Link to comment
https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576709
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.