xcandiottix Posted July 25, 2010 Share Posted July 25, 2010 <!--#include virtual="/includes/general/artdirector.php?position=top&&page=main" --> works on .HTML page <?php include('../includes/general/artdirector.php?position=top');?> doesn't work on .PHP page Is there a way to pass the variable "position" to artdirector.php from the .php page? edit => <?php include('../includes/general/artdirector.php');?> works on .PHP page, but need to pass variable 'position' none the less Quote Link to comment Share on other sites More sharing options...
joel24 Posted July 25, 2010 Share Posted July 25, 2010 use the header() function. i.e. this line will redirect user to URL header('Location: ../includes/general/artdirector.php?position=top'); Quote Link to comment Share on other sites More sharing options...
xcandiottix Posted July 25, 2010 Author Share Posted July 25, 2010 No, i'm not trying to redirect the user .. I am trying to include the artdirector.php page into another php page. The artdirector.php needs to know whether this include is at the top or bottom of a page. So, I'm trying to pass along where this include resides. artdirector.php then loads art work to the current viewed php page based on the position variable. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 25, 2010 Share Posted July 25, 2010 That's not what the OP wants. Since the file you're including is not a URL, you can't pass in a value with the file. But since the file is just being executed in the same scope as the main core, just set the variable before you include the file: <?php $position = 'top'; include('../includes/general/artdirector.php'); ?> Ken Quote Link to comment Share on other sites More sharing options...
xcandiottix Posted July 25, 2010 Author Share Posted July 25, 2010 Thanks ken, that put me in the right direction but also caused a problem. On the html page I use position=top at the top and position=bottom at the bottom. The top and bottom image sets show correctly. Using your method on the php page causes the top and bottom image sets to both be displayed at the top and the bottom: php page: top image set bottom image set top image set bottom image set Is there a way to fix this? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 25, 2010 Share Posted July 25, 2010 We have to see your code. Ken Quote Link to comment Share on other sites More sharing options...
xcandiottix Posted July 25, 2010 Author Share Posted July 25, 2010 index.html <!--#include virtual="/includes/general/artdirector.php?position=top&&page=main" --> ---html--- <!--#include virtual="/includes/general/artdirector.php?position=bottom&&page=main" --> people.php <?php $position = 'top'; include('../includes/general/artdirector.php');?> ---html data--- <?php $position = "bottom"; include('../includes/general/artdirector.php');?> artdirector.php <?php if($_GET['page'] == "main"){ session_save_path("/html/tmp/"); session_start(); } if(isset($_SESSION['active'])){ if($_GET['position'] || $position == "top"){ require_once('/html/includes/member/Logo-and-Banner-User-UP.html'); } if($_GET['position'] || $position == "bottom"){ require_once('/html/includes/member/Mlowernavbar.html'); } } else{ if($_GET['position'] || $position == "top"){ require_once('/html/includes/general/logobanner.html'); require_once('uppernavbar.html'); } if($_GET['position'] || $position == "bottom"){ require_once('/html/includes/member/general/lowernavbar.html'); } } ?> Thanks! Quote Link to comment Share on other sites More sharing options...
xcandiottix Posted July 25, 2010 Author Share Posted July 25, 2010 I noticed I said that the images are doubling up on the php page by mistake. Actually, on the PHP page the includes work perfectly. The problem is on the HTML page. <!--#include virtual="/includes/general/artdirector.php?position=top&&page=main" --> makes the top and bottom code to fire in both locations on the HTML page. Sorry I confused that. Quote Link to comment Share on other sites More sharing options...
xcandiottix Posted July 25, 2010 Author Share Posted July 25, 2010 DUH! :'( if($_GET['position'] || $position == "bottom"){ is wrong because it fires if get position exists. Stupid me.. fix is: if($_GET['position'] == "bottom" || $position == "bottom"){ Thanks for the help ken, i derailed myself =p Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.