Jump to content

many webpages in one php file


awiedman

Recommended Posts

You can do this:

 

index.php?Page=Links

 

 

index.php:

<body>
<?php
if($_GET['Links']) {
include("Links.php");
}
?>
</body>

 

 

If you do multiple pages do NOT do

<?php
include($_GET['Page'] . ".php");
?>

 

That leads to all types of injection and you don't want any part of that, if you get to use many more pages just use a switch statement and put all your possibilities in there.

As I said the switch statement is best for organization.

<?php
switch ($_GET['Page']) {
case "Links":
    include("Links.php");
    break;
case "About":
    include("AboutUs.php");
    break;
case "Contact":
    include("ContactUs.php");
    break;
default:
    echo("The page you have requested either no longer exists or has been moved to another location.");
}
?>

if($_GET['Links'])
{
$link = $_GET['Links'];
if(strcmp($link,'home')==)
{
	//	display home page
}
elseif(strcmp($link,'help')==0)
{
	//	display help page
}
else
{
	//	display default
}
}

 

something like that...

 

or yes, something like fearsoldiers' beat me to...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.