Page 1 of 1

if (url==what_i_want) ..............

Posted: Mon Feb 23, 2004 2:03 am
by apollovega
Is there a way to have it so

Code: Select all

<?
if (url == what_i_want)
     include("blah.php");
else
     include("black.php");

?>
basically is there a way to have it so when the brower says "http://www.somesite.com/someplace.php?page=somewhere" it'll execute a certain script. Any possible way?

Thanks for reading this :-D

P.s, don't bother running the code, it's just to explain it better since I have yet to improve my explaining skills. Thanks again.

Posted: Mon Feb 23, 2004 2:06 am
by markl999
if(!empty($_GET['page'])) {
require_once $_GET['page'].'.php';
} else {
require_once 'default.php';
}

You might also want to add some checking to make sure the file exists and that they don't/can't enter stuff like ?page=../../../../etc/passwd for example (though adding the .php on the end sorta stops anything useful, but still best to check paths).

Posted: Mon Feb 23, 2004 4:56 am
by apollovega
I see, thanks dood! :-) I'll try it out when I get a chance. Any chance of another way? Thanks a bunch :-)

Posted: Tue Feb 24, 2004 10:57 am
by AVATAr
markl999's way is the best _approach_