Jump to content

Php Inclusions.


cpugeek

Recommended Posts

I'm having a problem with my php inclusions.for some reason it doesn't work.I'm supposed to be able to access it @:http://127.0.0.1/index.php?x=PagenameI have 5 files total.Index.php, default.php.the other three are one, two, three.phphere's my code:

<?php // Include content if (is_file("$x.php")) { include("$x.php"); } else { include("default.php"); // the default page }  ?>

can anyone help me?Any & All help is appreciated.

Link to comment
Share on other sites

Could be what justsomeguy said, make sure $x has a value in your code.

<?php  $x=basename($_GET['x']);  $allow=array('index', 'default', 'one', 'two', 'three'); // Take out whatever files you want, or add more  if (file_exists("$x.php") && in_array($x, $allow)) {	include("$x.php");  }  else {	include("default.php");  }?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...