Reputation: 57
I am trying to create a dynamic website, the index.php includes the following code in the content area of the website:
<?PHP
// if undefined then define
if(!$od || $od == ""){
$od = "news";
}
// check if exists prep
$link = 'incs'."/".$od.$ext;
flush();
$fp = fopen($link, "r");
// check if inclusion file not exists then return error
if (!$fp) {
echo "An error has ocurred while processing your request. The file linked as ?od=".$od." does not appear to exist.";
}
// if exists then return parse
else {
fclose($fp);
include 'incs'."/".$od.$ext;
}
echo '</body>'."\n";
echo '</html>'."\n";
?>
I also have various links throughout the site to pages like register, login, etc. Those links point to pages like ?od=register, ?od=login, etc.
The website will pull the default file for me, news, and display that in my content section of my website, but when I click register, the url in the address bar DOES change to /?od=register, but the default news remains in the content section, is there an error in the code above? Or am I just missing something?
P.S. $ext
is defined in my config file as inc.php
, which is included at the top of the index page.
Upvotes: 0
Views: 314
Reputation: 71
I believe you need to define $od with a $_GET['od'] or $_REQUEST['od']
$od = $_GET['od'];
// if undefined then define
if(!$od || $od == ""){
$od = "news";
Upvotes: 0
Reputation: 25766
Besides the fact that this is very insecure - you are making a GET request, access the variables through the $_GET
array ie $od = $_GET['od']
Upvotes: 2