home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

I need a simple PHP script

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1574
Discussions: 200,954, Posts: 2,379,487, Members: 246,325
Old December 31st, 2003, 04:47 PM   Digg it!   #1 (permalink)
Member
 
Join Date: Jun 2002
Posts: 50
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 January 2nd, 2004, 11:18 AM     #2 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
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
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
jkrohn is offline   Reply With Quote
Old January 8th, 2004, 10:52 AM     #3 (permalink)
Ultimate Member
 
Praetorian's Avatar
 
Join Date: Oct 2001
Location: Arizona
Posts: 2,538
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 January 8th, 2004, 11:26 AM     #4 (permalink)
Member
 
drizzle's Avatar
 
Join Date: Oct 2001
Location: Louisiana, USA
Posts: 256
Send a message via MSN 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 : January 8th, 2004 at 11:28 AM.
drizzle is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2944)
The disrespect of Obama by Russian .. (41)
Making Health Care Worse (178)
Wireless Televisions. (12)
CPU fan stops spinning randomly (9)
Regular Build (11)
windows 7 problem (7)
Laptop with wireless problem. (5)
Is the PSU I received dead? (12)
radeon x850xt platinum & shader.. (6)
Print spooler problem (15)
windows vista security holes (11)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (11)
Recent Discussions
webcam (0)
upgrade for hp a6101 (0)
windows vista security holes (11)
Laptop with wireless problem. (5)
Modern Warfare 2: Who Bought It? (64)
tv not turn on-makes clicking sound (2)
CPU fan stops spinning randomly (9)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Internet Lost (3)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
Point and Shoot Camera Suggestions. (4)
Multiple Restarts Required at Boot (2)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)
For Sale BFG GTX285 OC2 with 10 year .. (3)
How to convert MP3's (4)
Wireless Televisions. (12)
Hp Artist Edition + Matching Bag (0)
Asus P4G8X Mobo (6)
Xbox 360 GTA: SA disk error (1)


All times are GMT -4. The time now is 05:50 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28