Page 1 of 1

open inside current page

Posted: Wed Jan 07, 2004 7:49 pm
by OX 3
is there a PHP code that allows me to open a page inside a site that uses include tags and then the code for the main page and when you click a link it changes ???

Posted: Thu Jan 08, 2004 12:11 am
by Gen-ik
Something like this will do it...

Code: Select all

<?php

if(!isset($_GET["page"]))
{
    $page = "news";
}
else
{
    $page = $_GET["page"];
}

?>

<html>
<head>
</head>
<body>

<?php include($page.".php") ?>

<hr />

<a href="?page=news">News Page</a><br />
<a href="?page=biog">Biog Page</a>

</body>
</html>
If you click on "News Page" then a file called news.php will be loaded, if you click on "Biog Page" then a file called biog.php will be loaded.


It should work :)

Posted: Thu Jan 08, 2004 1:05 am
by Weirdan

Code: Select all

else 
{ 
    $page = $_GET["page"]; 
}
makes xss attack possible. use [php_man]basename[/php_man]:

Code: Select all

else
{ 
    $page = basename($_GET["page"]); 
}