Forum Moderators: coopster

Message Too Old, No Replies

Help with variable

Works on one server, but not on another

         

katana_one

8:15 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



I have a script that works fine on one server, but not on another.

I think it may be a php version problem or maybe a security setting?

The page works fine on one server (my personal server), but when I upload it to the company server it doesn't work. What I have is a main template page that loads html documents into the body of the template.

Here is the code:

at the top of my document I have this:

<?php if ($page == "")
$page = "home"; ?>

and in the body of my document I have:

<?php
$filename = "$page" . ".htm";
if (file_exists($filename)) {
include "$filename";
} else {
echo "<div><h1>Oops!</h1>
<p>Sorry, that file does not exist or is unavailable at this time. Please check the URL or visit our home page and try another link!</div>";
}
?>

On one server (mine) it works as intended, loading the various html docs into the body of the page. On the company server, only the home page loads, no matter what link is clicked. Is there something I can do here to make sure it works on all servers? Did I use outdated or insecure code?

Any help is appreciated.

cameraman

8:30 pm on Jun 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You say 'at the top' - where does $page come from? If it's on the query string, try this:
<?php
if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 'home';

If that works then you have register_globals [us2.php.net] turned on and the company has it off.

katana_one

8:49 pm on Jun 5, 2008 (gmt 0)

10+ Year Member



Thanks, cameraman!

You're my hero.