php page will not process link to diff page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric W. Holzapfel

    php page will not process link to diff page

    Hello PHPers,
    I have just installed RH Linux ES 3.0 (basic) kernel 2.4.21-9.EL, i686,
    Apache 2.0.X, and php 4.2.X. I have made no changes to the php.ini.

    I am trying to use the following page (code listed here) to click on
    link, and display 1 of three pages. The code does not seem to work, it
    only shows the "else" condition of the php code, which is page:
    "stuff.php" . What do I need to do to my apache/php config to get this
    to work??? Of course I copied this code from a php site tutorial somewhere.

    Thanks,

    eric

    Page code below:
    <?
    if ($link == page2){
    $page="files/page2.html";
    }
    elseif($link == page3){
    $page="files/page3.html";
    }
    else{
    $page="files/stuff.php";
    }
    ?>
    <html>
    <head>
    <title> index.php </title>
    </head>
    <body bgcolor="#99999 9">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td colspan="3"><h1 >The Template (index.html)</h1></td>
    </tr>
    <tr>
    <td align="center" valign="top"><a href="index.php ?link=index">
    Page 1 </a></td>
    <td align="center" valign="top"><a href="index.php ?link=page2">
    Page 2 </a></td>
    <td align="center" valign="top"><a href="index.php ?link=page3">
    Page 3 </a></td>
    </tr>
    </table>
    <? include($page); ?>
    </body>
    </html>

  • Eric Bohlman

    #2
    Re: php page will not process link to diff page

    "Eric W. Holzapfel" <e.male@verizon .net> wrote in
    news:oNEQb.5250 $KU5.3285@nwrdd c02.gnilink.net :
    [color=blue]
    > I am trying to use the following page (code listed here) to click on
    > link, and display 1 of three pages. The code does not seem to work,
    > it only shows the "else" condition of the php code, which is page:
    > "stuff.php" . What do I need to do to my apache/php config to get this
    > to work??? Of course I copied this code from a php site tutorial
    > somewhere.[/color]
    [color=blue]
    > Page code below:
    > <?
    > if ($link == page2){
    > $page="files/page2.html";
    > }
    > elseif($link == page3){
    > $page="files/page3.html";
    > }
    > else{
    > $page="files/stuff.php";
    > }
    > ?>
    > <html>[/color]

    Where does $link get its value? Unless there's some other code you didn't
    show that sets it, it's going to be NULL and therefore neither of the first
    two comparison will succeed. Also, page2 and page3 really need to be
    quoted in the comparisons.

    Comment

    • Eric W. Holzapfel

      #3
      Re: php page will not process link to diff page

      Eric Bohlman wrote:[color=blue]
      > "Eric W. Holzapfel" <e.male@verizon .net> wrote in
      > news:oNEQb.5250 $KU5.3285@nwrdd c02.gnilink.net :
      >
      >[color=green]
      >>I am trying to use the following page (code listed here) to click on
      >>link, and display 1 of three pages. The code does not seem to work,
      >>it only shows the "else" condition of the php code, which is page:
      >>"stuff.php" . What do I need to do to my apache/php config to get this
      >>to work??? Of course I copied this code from a php site tutorial
      >>somewhere.[/color]
      >
      >[color=green]
      >>Page code below:
      >><?
      >> if ($link == page2){
      >> $page="files/page2.html";
      >> }
      >> elseif($link == page3){
      >> $page="files/page3.html";
      >> }
      >> else{
      >> $page="files/stuff.php";
      >> }
      >>?>
      >><html>[/color]
      >
      >
      > Where does $link get its value? Unless there's some other code you didn't
      > show that sets it, it's going to be NULL and therefore neither of the first
      > two comparison will succeed. Also, page2 and page3 really need to be
      > quoted in the comparisons.[/color]
      Hello and Thanks, I "thought" that $link gets set by clicking on the
      link on the index.php i.e. <href="index.ph p?link=page2"> Page 2 </a></td>
      here I thought the $link gets the value "page2"??? Obviously I am
      missing somthing (total beginner here!)
      It is not clear to me how $link can get set.

      Thanks for your help,
      eric

      Comment

      • Chris Jenkinson

        #4
        Re: php page will not process link to diff page

        Eric W. Holzapfel wrote:
        [color=blue]
        > Eric Bohlman wrote:
        >[color=green]
        >> "Eric W. Holzapfel" <e.male@verizon .net> wrote in
        >> news:oNEQb.5250 $KU5.3285@nwrdd c02.gnilink.net :
        >>[color=darkred]
        >>> I am trying to use the following page (code listed here) to click on
        >>> link, and display 1 of three pages. The code does not seem to work,
        >>> it only shows the "else" condition of the php code, which is page:
        >>> "stuff.php" . What do I need to do to my apache/php config to get this
        >>> to work??? Of course I copied this code from a php site tutorial
        >>> somewhere.[/color]
        >>
        >>
        >>[color=darkred]
        >>> Page code below:
        >>> <?
        >>> if ($link == page2){
        >>> $page="files/page2.html";
        >>> }
        >>> elseif($link == page3){
        >>> $page="files/page3.html";
        >>> }
        >>> else{
        >>> $page="files/stuff.php";
        >>> }
        >>> ?>
        >>> <html>[/color]
        >>
        >>
        >>
        >> Where does $link get its value? Unless there's some other code you
        >> didn't show that sets it, it's going to be NULL and therefore neither
        >> of the first two comparison will succeed. Also, page2 and page3
        >> really need to be quoted in the comparisons.[/color]
        >
        > Hello and Thanks, I "thought" that $link gets set by clicking on the
        > link on the index.php i.e. <href="index.ph p?link=page2"> Page 2 </a></td>
        > here I thought the $link gets the value "page2"??? Obviously I am
        > missing somthing (total beginner here!)
        > It is not clear to me how $link can get set.
        >
        > Thanks for your help,
        > eric
        >[/color]


        You should add this line to the top of the page (after the <?php) if you
        want $link to contain the variable 'link' from the querystring:

        $link = $_GET['link'];

        You should also add single quotes ( ' ) around page2 and page3 in your
        if statement.

        Chris

        Comment

        Working...