I'm creating a site and want to use this "effect" where its the same php page, but its like different sites, with id's though.
I'm dumb with php, so if anybody can run down how to do this, I'd greatly appreciate it.
I'm creating a site and want to use this "effect" where its the same php page, but its like different sites, with id's though.
I'm dumb with php, so if anybody can run down how to do this, I'd greatly appreciate it.
Save your files as *.php and save them in the same folder as the script. Link to the individual pages as <a href="index.php?id=home"> etc.Code:<?php include($_GET['id'].".php"); ?>
Wow, thank you.
This was exactly what I was looking for![]()
Correct me if I am wrong, but can't someone load a remote php page and destroy your site using that?Originally Posted by celebraces
would that help prevent people from messing up your site?PHP Code:<?php
$page = $_GET['id'];
if (file_exists("public_html/$page.php")) {
include("$page.php");
} else { echo "file not found"; }
?>
Last edited by dharmil; 07-26-2006 at 03:57 PM.
- Dharmil
Instead of using .php?id=something, look into permalinks and mod_rewrite. X10 supports rewrite rules, and they can help the security of your site and look a helluva lot nicer than ?id=...
Instead of yourdomain.com/index.php?id=something&a=b you would have yourdomain.com/something/b/ or similar.
Getting Started | Terms of Service | Paid Hosting | Forum Rules | Free Server Status | Banned Countries
If I have helped you through one of my posts, please click the
blue checkbox on the right below my avatar to add to my reputation.
is this how you would do it?Originally Posted by The_Magistrate
in htaccess file
RewriteRule index/(.*)$/(.*)$ /index.php?id=$1&a=$2
- Dharmil
i wrote about a solution for this after seeing your thread in my PHP includes tutorial.Originally Posted by Nate_Benton
- XiRE
In the script above, if someone where to go to index.php, it would show the home.php file. If someone where to go to index.php?id=faq, faq.php would load but the url would still look like index.php?id=faqPHP Code:<?php
function index()
{
include ("home.php");
}
$choice=$_GET['id'];
switch($choice)
{
case "faq":
include ("faq.php");
break;
case "tutorials":
include ("tuts.php");
break;
default:
index();
}
?>
This is just an example of what you can use to fit your needs. You don't have to use includes for this to work. I just did b/c that is the simplest way.
Last edited by Tomballa; 07-28-2006 at 03:20 PM.