I think you are looking for something like this:

$page = array_key_exists( 'page', $_GET ) ? GET['page'] : 'index';

Then you MUST sanitize the $page variable.

I often use the querystring to wrapp the module you are requesting:

www.example.org/?path/to/molude (note that .htaccess is required)

# the you can access by
echo $path = $_SERVER['QUERY_STRING'];

On Wed, Aug 5, 2009 at 2:19 PM, Allen McCabe<allenmcc...@gmail.com> 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?
> On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn <jerrywilb...@gmail.com>wrote:
>
>> 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
>> jerrywilb...@gmail.com
>>
>>
>>
>> On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe <allenmcc...@gmail.com>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!
>>>
>>
>>
>



-- 
Martin Scotta

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

Reply via email to