»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 12-31-2003, 01:47 PM   #1 (permalink)
Registered User
 
Join Date: Jun 2002
Posts: 47
Spook01 is on a distinguished road
I need a simple PHP script

I have a index page with a php query to include a "default.php" page as my content in the contents section.

Im sure youve all seen those links where they have the urls shaped like, "www.website.com/index.php?page=otherpage".

How would i get it to where if no variables are present in the url, the page would do a "include default.php" line, and if there are variables present, then the page would ignore the default include and do something like, "include '$page.php'"?

Spook01 is offline   Reply With Quote
Old 01-02-2004, 08:18 AM   #2 (permalink)
Registered User
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Champaign, IL
Posts: 3,253
jkrohn is on a distinguished road
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
Code:
if(!$page)
      include otherpage.php
else{
     load other pages here with either a switch function or nested ifs
}
That should work for you. If nothing is passed then the $page variable should not exist.

Jkrohn
__________________
Jkrohn
jkrohn is offline   Reply With Quote
Old 01-08-2004, 07:52 AM   #3 (permalink)
Registered User
 
Praetorian's Avatar
 
Join Date: Oct 2001
Location: Yuma, AZ
Posts: 2,484
Praetorian is on a distinguished road
Send a message via ICQ to Praetorian Send a message via AIM to Praetorian Send a message via Yahoo to Praetorian
Correct me if I'm wrong, but wouldn't page exist if the URL was something like this?

http://www.mysite.com/index.php?page=

In that case would you use an

Quote:
if(empty($page))
{
include otherpage.php
}else{
load other pages here with either a switch function or a nested ifs
}
Praetorian is offline   Reply With Quote
Old 01-08-2004, 08:26 AM   #4 (permalink)
Registered User
 
drizzle's Avatar
 
Join Date: Oct 2001
Location: Louisiana, USA
Posts: 170
drizzle is on a distinguished road
Send a message via ICQ to drizzle Send a message via Yahoo to drizzle
PHP Code:
$page $_GET['page'];
$path "includes/";
$extension '.php';

if (!
$page) {
     include 
'default.php';
} else {
     
$filename $path.$page.$extension;
     include(
$filename);

This would keep files that shouldn't be access from being pulled up with it. Incase someone decided to get creative with your URL. Also, register_globals is off by default in PHP 4.2.0 and later as a security measure. It's actually best to leave it as that and get variables through the superglobal arrays.

Last edited by drizzle; 01-08-2004 at 08:28 AM.
drizzle is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 12:35 PM.