I have 3 levels of pages nested one into another:
1st level: index.php
2nd level: header.php, body.php, footer.php
3rd level: news.php, newsdetail.php, newsadd.php, traffic.php, trafficdetail.php etc.
For security reasons I have created functions in the 2nd and the 3rd level pages, to display them, so they are displayed in the parent page by invoking these functions.
The problem is in going from news.php to newsdetail.php.
To open newsdetail.php i have to pass 2 different parameters: option (which in our case is news_detail), and newsid. The first parameter passes well from news to news detail, as i receive the newsdetail.php page, but the sql query doesnt get populated.
For security reasons, i am using functions to display the pages.
To display newsdetail.php i am using ShowNewsDetail() function, to display body.php I am using ShowBody() function.
The basic structure for a page is like this:
---for index.php
<?php
include ("header.php");
include ("body.php");
include ("../footer/footer.php");
?>
<?php require_once('../Connections/ARRH.php'); ?>
<html>
<head>
</head>
<body >
<table>
<tr>
<td >
<?php ShowHeader() ?>
</td>
<td></td>
</tr>
<tr>
<td colspan="23">
<?php ShowBody() ?>
</td>
</tr>
<tr>
<td colspan="23"><?php ShowFooter()?></td>
</tr>
</table>
</body>
</html>
--body.php
<?php
function ShowBody()
{
?>
<body>
<?php
////////////////////////////////////////////////////////////////////////////////////////////
// I am collecting the URL variable (menu_option) regarding the menu option the visitor choses:
// Possible values: menu_option = noticias_index
// menu_option = feedback_index
// menu_option = trafico_cumulative
// menu_option = trafico_monthly
// menu_option = trafico_yearly
// menu_option = trafico_weekly
// menu_option = noticias_modify
// menu_option = noticias_detail
// menu_option = noticias_add
////////////////////////////////////////////////////////////////////////////////////////////
if (isset($GET['menu_option'])) {
$menu_option = (get_magic_quotes_gpc()) ? $GET['menu_option'] : addslashes($_GET['menu_option']);
}
else {
$menu_option = "trafico_index";
}
switch ($menu_option) {
case "noticias_index":
include("./noticias/noticias_index.php");
ShowNoticiasIndex();
break;
case "feedback_index":
include("./feedback/feedback_index.php");
ShowFeedbackIndex();
break;
case "trafico_cumulative":
include("./trafico/trafico_cumulative.php");
ShowTraficoCumulative();
break;
case "trafico_weekly":
include("./trafico/trafico_weekly.php");
ShowTraficoWeekly();
break;
case "trafico_yearly":
include("./trafico/trafico_yearly.php");
ShowTraficoYearly();
break;
case "trafico_monthly":
include("./trafico/trafico_monthly.php");
ShowTraficoMonthly();
break;
case "noticias_modify":
include("./noticias/noticias_modify.php");
ShowNoticiasModify();
break;
case "noticias_add":
include("./noticias/noticias_add.php");
ShowNoticiasAdd();
break;
case "noticias_detail":
include("./noticias/noticias_detail.php");
ShowNoticiasDetail();
break;
default:
include("./trafico/trafico_cumulative.php");
ShowTraficoCumulative();
}
?>
</td>
</tr>
</table>
<?php
}
?>
--then we have the noticias_index.php which displays the news, and according to it, noticias_detail.php, displayed by ShowNoticiasDetail() functions called within noticias_index.php
I guess you got my point... its a rather sticky issue with all this nesting.
The problem is that when i call the noticias_detail.php from noticias_index.php, I receive on the first one the menu_option parameters, but not the newsid parameter. There could be 2 possible issues:
1. the level of nesting is too deep and php doesnt allow this
2. i am passing noticiaid parameter from one function to another ... and it is a problem at the functions.
That is why i am asking for others opinion about this.