Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

(PHP) One Page Script

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch

Webviper2006

Established Member
Impact
0
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:
<? 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? :hehe:
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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.
 
0
Close
Eh. I never knew that. Listen to him. Nice work, I never knew that.
 
0
Close
theres another way to do this

PHP:
<?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
 
0
Close
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.
 
0
Close
This will also work,
PHP:
$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.
 
0
Close
webmonkey, your script would give errors instead of a default page, which is usually not wanted.
 
0
Close
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[''])
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back