Forum Moderators: coopster
I want to create a condition that displays certain code on certain pages of the site. The logic would be something like this:
if page <> main.php?downloads.php then
show this code
else
show nothing
end if
or should I just declare a variable on the page where I don't want the code to show and then use the logic to reference that variable?
$page = 0 //put this on the page where I don't want it to show
$page = 1 //put this on all other pages
if page = 1 then
show this code
else
show nothing
Can someone help me with the syntax?
TIA.
//////// index.php //////////
<?
$page = $_REQUEST['page']; //gets variable passed to index.php?page=, in this case it would be index.php?page=downloads
if(strcasecmp($page, "downloads")==0){
//insert code here for downloads (or insert downloads.php template)
}
/* or a more efficient (and shorter) method so you wont have to make many if statements*/
$page= $page.".php";
if(file_exist($page)){
include($page);
}
else{
echo "This page is non existent";
}