problem with page calling by name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mumick
Forum Newbie
Posts: 2
Joined: Mon Feb 16, 2004 2:25 am
Location: Milwaukee, WI

problem with page calling by name

Post by mumick »

Hi everyone. I need some help with php. Here is the problem. I am trying to figure out how to call pages either by their name or by id. Its like index.php?page=pagename or index.php?id=pagename. For that reason I found a script at http://www.krahs-emag.com/files/. I uploaded it to my web server but it doesn't work, it always displays the main page. I don't know what's wrong. I went through all settings that needed to be adjusted but no luck. I have my main page as index.htm and I got several "htm" pages that I would like to call. Can someone do me a favour and test the script maybe there is a bug in it.
*************************************************************
//Setup Variables
$defpage = "index"; //default page
$defpage .= ".htm"; //defalt extension
$path = ""; //path to pages reletive to this script
$active = "1"; //1=yes 0=no. If active is off, only the default page will work


//Configuration Variables
//Set the order in which you want the script to look for extensions
$ext_array = array(
'.htm',
'.html' ,
'.php' ,
'.php3',
'.php4');


$page = $_GET['page'];
$page_hold = $page;
$fullurl = null;
If ($active==0){
$page = $defpage;
include $path.$page;
}elseif ($active==1){
If (!isset($page)) {
$page = $defpage;

}else{
If (file_exists($path.$page)){
if (!isset($msg)){
$msg = $_GET['msg'];
}
include $path.$page;
$fullurl = 1;
}else{

foreach($ext_array as $ext){
$page = $page_hold;
$msg = null;
if(file_exists($path.$page.$ext)){
$page .= $ext;
break;


}else{
$page = $defpage;
$msg = "<b>Invalid page</b> - returning to index.";
}
}
}
}


if (!isset($fullurl)){
if (!isset($msg)){
$msg = $_GET['msg'];
}
include $path.$page;
}
}else{
Echo "<center><b>Script Incorrectly Configured, check settings</b></center>";
}
if ($debug==1){
Echo "<u>Output variables</u>";
Echo "<br> \$msg=".$msg."<br> page=".$page;
}
?>
************************************************************
that what I've got in index.htm
I am calling "about_us.htm" page by placing a link ->
"index.php?page=about_us". I also tried to call it using the full path
"http://www.youdomain.com/index.php?page=about_us" and also this way
"index.php?page=about_us.htm"
but I didn't get any result, it always displays the main page. Maybe someone has a better idea on how to implement my idea or at least post has a link to where I can find info. Thanks in advance, I really appreciate your help.
User avatar
softsolvers
Forum Commoner
Posts: 75
Joined: Fri Feb 13, 2004 4:26 am
Location: India

Post by softsolvers »

check the php.ini config of your server
Post Reply