FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


$page= and include problems





polly-gone
Hey I have a question. When I do this:

Code:
$start = '/home/username/domains/yourdomain/public_html/';
$nav = $_GET['nav'];
if(file_exists($start.$nav.'.php')){
   include($start.$nav.'.php');
}
else {
   header('Location: http://yourdomain/403.shtml');
}


How do I make http://yourdomain.com load http://yourdomain.com/$page=index ?

Thanks ahead of time!

-Nick Smile Smile Smile
Diablosblizz
What is $page being used for? And are you talking about the

index.php?page=index?
Peterssidan
If you mean something similar to http://yourdomain.com/index.php?page=index you can put this in .thaccess file:

Code:
DirectoryIndex index.php?page=index


I guess you can do like that but I havn't tried.
roboguyspacedude
this is the code I usally use to include a page news.php or any content into a certain spot on my site. put this code where you want the content to load.
Code:
<?php
$page = $_GET['page'];
if($page == null || $page == ""){include "defaultpage.php"; }else{include $page; }
?>

and make all of your urls be like
Code:
<a href="?page=news.php">News</a>

alternatively if you want the url not to contain .php at the end so people won't know exactly what file you're talking about use:
Code:
<?php
$page = $_GET['page'];
if($page == null || $page == ""){include "defaultpage".php; }else{include $page.".php"; }
?>

and make all of your urls be like
Code:
<a href="?page=news">News</a>
polly-gone
I already know how to load things in PHP (see my first post.) What I want to know is how do I load index.php?page=index. I want the main thing to load. Otherwise it loads a blank page and you have to click link that says home to get to the home page.
AftershockVibe
Can't you just change the code in index.php so that if $_GET['page'] is empty (or undefined, or invalid, or whatever) that it sets it to "index" automatically?
polly-gone
Hmm... I never thought of that... Thanks!!!

-Nick Smile Smile Smile
Diablosblizz
Code:
<?php
switch($_GET['page']) {
default:
// STUFF HERE
break;

case 'index':
//INDEX PAGE HERE
break;
}
?>


That will also work.
polly-gone
Thanks. And awesome avatar Diablosblizz. Lol

-Nick Smile Smile Smile
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.