Page 1 of 1

help using url formatting

Posted: Tue Aug 24, 2004 3:34 pm
by scrupul0us
i want to use url formatting like this:

index.php?page=pagename.htm

how do i pass "pagename.htm" to

include ("pagename.htm");

Posted: Tue Aug 24, 2004 3:37 pm
by dull1554
if your url looks like index.php?page=pagename.htm and you want to include pagename.htm do this

Code: Select all

include ($_GET['page']);

Posted: Tue Aug 24, 2004 3:39 pm
by feyd
warning: blindly including a page is dangerous. make sure you filter the sent page to make sure it's one you want to be able to load..

Posted: Tue Aug 24, 2004 3:44 pm
by dull1554
how right you are feyd it would be a good idea to have an array of avaiable pages like this

Code: Select all

$array = array("blah.htm","somepage.htm","anypage.htm");
if (in_array($_GET['page'],$array)) include ($_GET['page']);
else echo "access denied";

Posted: Tue Aug 24, 2004 4:11 pm
by scrupul0us
hrm... when i try:

/index.php?page=question.htm

where it should be included just comes up blank...

heres the code:

<?php
$array = array("support.htm","question.htm","contact.htm","question.htm");
if (in_array($_GET['page'],$array)) include ($_GET['page']);
else echo "access denied";
?>

should also add that this php page is in:

/wwwroot/

and the htm pages are in:

/wwwroot/htm