NameSilo

(PHP) One Page Script

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
•••
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
•••
Eh. I never knew that. Listen to him. Nice work, I never knew that.
 
0
•••
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
•••
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
•••
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
•••
webmonkey, your script would give errors instead of a default page, which is usually not wanted.
 
0
•••
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
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back