Page 1 of 1
Include Using Parent Variables
Posted: Wed Dec 21, 2005 11:44 pm
by AliasBDI
I have two pages. Page1 includes Page2. Page1 is being called to a frame by a URL that contains a query string ("/page1.php?var=foo"). Page2 is supposed to use this string variable in its execution. So Page2 has code which reads:
Code: Select all
$getVAR = $_REQUEST['var']; echo $getVAR;
Nothing appears. I also tried this by creating session variables in Page1. Any ideas on this? Should this even work?
Posted: Thu Dec 22, 2005 12:00 am
by AGISB
if you include a page it should contain the var already in this case try $_SERVER['QUERY_STRING']
Posted: Thu Dec 22, 2005 8:38 am
by AliasBDI
If I use session variables, should I have session_start(); at the beginnig of each page and the page includes as well? OR do I just need one on the parent page?
Posted: Thu Dec 22, 2005 8:49 am
by AliasBDI
Maybe there is something wrong in my code. Can you check?
Page1:
Code: Select all
<?php
session_start();
include("../../../_common/incCOMMON.php");
include("../../../_common/incNOCACHE.php");
?>
<link href="<?php echo conSITEURL.conECTEMPLATEPATH; ?>/css/main.css" rel="stylesheet" media="all">
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="middle">
<td width="20" background="<?php echo conSITEURL.conECTEMPLATEPATH; ?>/graphics/main/midbg.jpg"><img src="<?php echo conSITEURL.conECTEMPLATEPATH; ?>/graphics/main/midbg.jpg" width="20" height="43"></td>
<td background="<?php echo conSITEURL.conECTEMPLATEPATH; ?>/graphics/main/midbg.jpg">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><span class="areaTITLE"><span class="capitolize"><b><?php include_once(conSITEURL.conECTEMPLATEPATH.'/get/getAREA.php'); ?></b></span></span></td>
<td><span class="areaTITLE"><span class="capitolize"><b><?php //include_once(conSITEURL.conECTEMPLATEPATH.'/get/getSUBAREA.php'); ?></b></span></span></td>
<td><?php //include_once(conSITEURL.conECTEMPLATEPATH.'/get/getACTION.php'); ?></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
Page2 (getAREA.php):
Code: Select all
<?php
session_start();
include("../../../_common/incCOMMON.php");
include("../../../_common/incNOCACHE.php");
// CREATING THE AREA TITLE
$getAREA = $_REQUEST['getAREA'];
echo $getAREA;
if (empty($getAREA) || $getAREA="home"){
$getAREA = conSITENAME." Management";
echo "</span></span><font color=\"#FFFFFF\" class=\"areaTITLE\"><b>".$getAREA."</b></font><span class=\"capitolize\">";
} else {
$_SESSION['getAREA'] = $getAREA;
echo "<a href=\"".conECTEMPLATEPATH."/ec".$getAREA.".asp\" target=\"content\" onClick=\"top.frames['subheader'].location.href='".$getAREA."/frames/subheader.asp?getAREA=".$getAREA."'\" class=\"areaTITLE\"><b>".$getAREA."</b></a>";
}
?>
Posted: Thu Dec 22, 2005 9:11 am
by josh
Stick a
in page 2, right before you are assigning the variable in question, also try sticking this right before the include on page 1