Jump to content

Help with simple script after upgrade from PHP4 to PHP5


lang2583

Recommended Posts

I have this simple templating script I've been using for a while on a server w/ PHP4. It was upgraded to PHP5 and won't work any more. Any help?

<?php

include("header.php");
echo "";
$id="/home/username/public_html/content/$id.html";
if (file_exists($id)) {
include($id);
} else {
include("error.php");
};
include("footer.php");

?>
Don't enable register globals! Try...

[code]
<?php

include("header.php");
echo "";
$id="/home/username/public_html/content/{$_GET['id']}.html";
if (file_exists($id)) {
  include($id);
  } else {
      include("error.php");
};
include("footer.php");

?>
[/code]

Asuming the initial $id is coming through the url.
[quote author=thorpe link=topic=113657.msg462022#msg462022 date=1162506221]
Don't enable register globals! Try...

[code]
<?php

include("header.php");
echo "";
$id="/home/username/public_html/content/{$_GET['id']}.html";
if (file_exists($id)) {
   include($id);
   } else {
      include("error.php");
};
include("footer.php");

?>
[/code]

Asuming the initial $id is coming through the url.
[/quote]

Perfect. Many thanks!!!  ;D
thorpe:

Yeah I will admit changing to the proper either $_GET or $_POST is the proper fix, but if he has many, many, other pages he is going to encounter the same error all over the place.

So, instead of manually chaning all variables, which is a HUGE pain in the butt, register_globals is the easiet fix, assuming security inst a main concern. Although, I will be the first to admit, if you have time, worth going and changing all your variable to the proper either $_GET and $_POST.

Everything I write now, I dont rely on register_globals, but older applications I have written, which do rely on register_globals I am not going to try and fix them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.