View Full Version : just a quick one [php]
Swearwolf
30-09-2007, 03:30 PM
So Ive got this code on my index.php page
<?php
if($_GET['page']) {
$page = $_GET['page'];
$page = str_replace(".", "", $page);
$page = "".$page.".php";
if(file_exists($page)) {
include("$page");
} else {
include("404.php");
}
}
else {
include("home.php");
}
?>
and I have no idea what format the link would be.. i.e "blahblah.php?lolol" or something? any help xD +rep
Invent
30-09-2007, 03:34 PM
Ha :p
That's my old include script that I wrote ^______^
Do, file.php?page=yourpage
(:
Swearwolf
30-09-2007, 03:34 PM
yep it is :)
and thanks
(needa spread repz)
Invent
30-09-2007, 03:41 PM
<?php
$get_req = "page"; /* Change this to what you want to use to control the page. (If you choose "page" then you'd to yourfile.php?page=index */
$home_file = "home.php"; /* Change this to your home file so that it loads if no other file is specified (There is no ?var=) */
$error_file = "404.php"; /* Change this to your 404 File not found page which loads if the file specified doesn't exist */
if( $_GET[ $get_req ] )
{
$page = $_GET[ $get_req ];
$filter = array("http://", ".");
$page = str_replace( $filter , "", $page);
$page = $page.".php";
if( file_exists( $page ) )
{
include($page);
}
else
{
include( $error_file );
}
}
else
{
include( $home_file );
}
?>
Is a better code by the way :)
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.