FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a 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

New forum area (computer problems)
Main page layout problems / Grammar problems in directory
positioning div top right
Some designing help
Login Scripts

what are the differents between require and include
PHP Navigation
Frames, Tables, iFrames
Wonders of the include() in PHP.
Loading time?

[PHP] Dynamic content
Interest in Environmentally Conscious website
PHP Problem...
one line securing of php pages (login of users) (user auth)
IP Range related question...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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