[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-12-2006, 10:45 PM   · #1
Webviper2006
NamePros Member
 
Trader Rating: (0)
Join Date: Dec 2005
Posts: 37
NP$: 0.00 (Donate)
Webviper2006 is an unknown quantity at this point
(PHP) One Page Script

Hi I just made a script that actaully really works! This is how it works. But it's only for PHP.

Files Needed:
index.php
home.php
news.php

File "index.php"

PHP Code:
<? if($id) { include("$id.php"); } else { include("home.php"); } ?>


Now you put it on the middle of the page in index.php
Make a link like this...

Code:
<a href="index.php?id=news">News</a>


So? Does it work?


Please register or log-in into NamePros to hide ads

Last edited by Webviper2006 : 04-12-2006 at 10:53 PM.
Webviper2006 is offline   Reply With Quote
Old 04-12-2006, 11:14 PM   · #2
CreedFeed
NamePros Member
 
CreedFeed's Avatar
 
Trader Rating: (1)
Join Date: Apr 2006
Posts: 175
NP$: 160.00 (Donate)
CreedFeed is on a distinguished road
Try modifying that a bit:

Code:
<? if (isset($id) and file_exists("$id.php")) { include("$id.php"); } else { include("home.php"); } ?>


Prevent someone from trying to run malicious code via your page.
CreedFeed is offline   Reply With Quote
Old 04-13-2006, 09:12 AM   · #3
Webviper2006
NamePros Member
 
Trader Rating: (0)
Join Date: Dec 2005
Posts: 37
NP$: 0.00 (Donate)
Webviper2006 is an unknown quantity at this point
Eh. I never knew that. Listen to him. Nice work, I never knew that.
Webviper2006 is offline   Reply With Quote
Old 04-13-2006, 10:14 AM   · #4
adam_uk
Senior Member
 
Trader Rating: (17)
Join Date: May 2003
Posts: 2,211
NP$: 6170.25 (Donate)
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
Breast Cancer
theres another way to do this

PHP Code:
<?php
   
switch (urlencode($_GET['go'])) {
       case
"contact": $inc = 'contact.php';
       break;
       case
"downloads": $inc = 'downloads.php';
       break;
       default:
$inc = 'mainPage.php';
       break;
   }
   include (
$inc);
?>


so if i pass this: index.php?go=contact i end up with ocntact.php
if i call index.php i end up at mainPage.php (Because go is null)
if i pass index.php?go=HACK;cat /etc/passwd;

i end up at mainPage because I didnt match the switch.

the urlencode will stop anything nasty being passed in the url
adam_uk is offline   Reply With Quote
Old 04-13-2006, 11:14 AM   · #5
Webviper2006
NamePros Member
 
Trader Rating: (0)
Join Date: Dec 2005
Posts: 37
NP$: 0.00 (Donate)
Webviper2006 is an unknown quantity at this point
Or maybe if you got no php website well I just made a HTML code that does the same thing!

Code:
<iframe name="iframe" width="200" height="300 src="home.html"></iframe>


And then when you make a link...

Code:
<a href="news.html" target="iframe">NEWS CLICK HERE</a>


Try that. I think this works better and more better and easyier.
Webviper2006 is offline   Reply With Quote
Old 04-13-2006, 12:36 PM   · #6
Xyzer
Steven
 
Xyzer's Avatar
 
Name: Steven Gibbons
Location: United Kindom
Trader Rating: (45)
Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 (Donate)
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
Tsunami Relief AIDS/HIV
This will also work,
PHP Code:
$id = $_GET['id'];
if(!empty(
$id)){
  if (
file_exists($id . ".php")) {
     include(
$id. ".php");
  }else{
     include(
"error.php"); //error page not found
  
}                      
}else{
     include(
"index.php");//or some other default doc
}

Basically, /?id=contact would load contact.php and /?id=home would loads home.php.
Xyzer is offline   Reply With Quote
Old 04-13-2006, 07:07 PM   · #7
Palyriot
NamePros Regular
 
Palyriot's Avatar
 
Name: Derek
Location: Seattle, Wa
Trader Rating: (14)
Join Date: Jul 2004
Posts: 597
NP$: 69.00 (Donate)
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
webmonkey, your script would give errors instead of a default page, which is usually not wanted.
Palyriot is offline   Reply With Quote
Old 04-16-2006, 06:46 AM   · #8
softgroups
NamePros Regular
 
Name: BOgdan
Location: Romania
Trader Rating: (4)
Join Date: Sep 2005
Posts: 492
NP$: 121.10 (Donate)
softgroups will become famous soon enoughsoftgroups will become famous soon enough
try to not use global variables! Try using if(isset($_Get[''])

try to not use global variables! Try using if(isset($_Get[''])

try to not use global variables! Try using if(isset($_Get[''])
__________________
Free PHP Scripts - Free online php scripts collection
http://www.iseotools.com - SEO Tools
softgroups is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Hunting Moon EscrowDNS EscrowDNS
Advertise your business at NamePros
All times are GMT -7. The time now is 10:19 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0