Passing multiple variables using GET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dariusz

    Passing multiple variables using GET

    I have a problem where I need to pass two variables using GET from a form I
    have, to solve a page selection problem I have.

    The code is written that if a new visitor arrives at the front page of the
    site, because the page id is null, PHP loads the default design. But when
    I execute one of my other pages which has a form on it, because I cannot
    pass back the id of the page that the form is on (the "submit" GET's the
    desired page id only), instead of calling the new page, it executes the
    "null" part of the script again. Despite the GET having a different id
    (track), it refuses to execute because the page == null code.

    The variable of the page needed to be displayed is GET'ed (it's in the
    browser URL, and an echo statement in the PHP confirms the value GET'ed,
    and lack of the original page id.

    How can I get the code to pass both the page id and the data of the
    selected form item at the same time?

    Dariusz


    The PHP

    <?
    if ($_GET['page'] == NULL)
    {
    echo $_GET['track']; //value passed from the HTML form
    echo $_GET['page']; //value of the page id
    include ("index2.php ");
    }
    elseif ($_GET['page'] == index)
    {
    header ("Location: /index.php");
    }
    elseif ($_GET['page'] != index)
    {
    include ("html/".$_GET['page'].".shtml");
    }
    elseif ($_GET['track'] == a01-t01)
    {
    include ("html/lyrics/".$_GET['track'].".htm");
    }

    ?>


    The form HTML

    <FORM method="GET" action="../../index.php" name="myform01" >
    <select name="track">
    <option value="a01-t01" SELECTED>Track 01</option>
    <option value="a01-t02">Track 02</option>
    <option value="a01-t03">Track 03</option>
    <option value="a01-t04">Track 04</option>
    </select>
    <BR><BR>
    <input type="submit" value="Go get the lyrics">
    </FORM>
  • Dag Sunde

    #2
    Re: Passing multiple variables using GET

    Put the page id in a hidden field in the form, then it will be
    sendt together with the rest of the forms fields.

    --
    Dag.


    "Dariusz" <ng@lycaus.plus YOURSHIT.com> wrote in message
    news:MOnEb.2485 $tQ6.32376@ward s.force9.net...[color=blue]
    > I have a problem where I need to pass two variables using GET from a form[/color]
    I[color=blue]
    > have, to solve a page selection problem I have.
    >
    > The code is written that if a new visitor arrives at the front page of the
    > site, because the page id is null, PHP loads the default design. But when
    > I execute one of my other pages which has a form on it, because I cannot
    > pass back the id of the page that the form is on (the "submit" GET's the
    > desired page id only), instead of calling the new page, it executes the
    > "null" part of the script again. Despite the GET having a different id
    > (track), it refuses to execute because the page == null code.
    >
    > The variable of the page needed to be displayed is GET'ed (it's in the
    > browser URL, and an echo statement in the PHP confirms the value GET'ed,
    > and lack of the original page id.
    >
    > How can I get the code to pass both the page id and the data of the
    > selected form item at the same time?
    >
    > Dariusz
    >
    >
    > The PHP
    >
    > <?
    > if ($_GET['page'] == NULL)
    > {
    > echo $_GET['track']; //value passed from the HTML form
    > echo $_GET['page']; //value of the page id
    > include ("index2.php ");
    > }
    > elseif ($_GET['page'] == index)
    > {
    > header ("Location: /index.php");
    > }
    > elseif ($_GET['page'] != index)
    > {
    > include ("html/".$_GET['page'].".shtml");
    > }
    > elseif ($_GET['track'] == a01-t01)
    > {
    > include ("html/lyrics/".$_GET['track'].".htm");
    > }
    >
    > ?>
    >
    >
    > The form HTML
    >
    > <FORM method="GET" action="../../index.php" name="myform01" >
    > <select name="track">
    > <option value="a01-t01" SELECTED>Track 01</option>
    > <option value="a01-t02">Track 02</option>
    > <option value="a01-t03">Track 03</option>
    > <option value="a01-t04">Track 04</option>
    > </select>
    > <BR><BR>
    > <input type="submit" value="Go get the lyrics">
    > </FORM>[/color]


    Comment

    • Dariusz

      #3
      Re: Passing multiple variables using GET

      In article <bRnEb.28726$BD 3.5758760@julie tt.dax.net>, "Dag Sunde" <dag.nope@orion .no.way> wrote:[color=blue]
      >Put the page id in a hidden field in the form, then it will be
      >sendt together with the rest of the forms fields.[/color]

      Oh thanks - works great :-)

      Dariusz

      Comment

      • CountScubula

        #4
        Re: Passing multiple variables using GET

        "Dag Sunde" <dag.nope@orion .no.way> wrote in message news:<bRnEb.287 26$BD3.5758760@ juliett.dax.net >...[color=blue]
        > Put the page id in a hidden field in the form, then it will be
        > sendt together with the rest of the forms fields.
        >
        > --
        > Dag.
        >
        >
        > "Dariusz" <ng@lycaus.plus YOURSHIT.com> wrote in message
        > news:MOnEb.2485 $tQ6.32376@ward s.force9.net...[color=green]
        > > I have a problem where I need to pass two variables using GET from a form[/color]
        > I[color=green]
        > > have, to solve a page selection problem I have.
        > >
        > > The code is written that if a new visitor arrives at the front page of the
        > > site, because the page id is null, PHP loads the default design. But when
        > > I execute one of my other pages which has a form on it, because I cannot
        > > pass back the id of the page that the form is on (the "submit" GET's the
        > > desired page id only), instead of calling the new page, it executes the
        > > "null" part of the script again. Despite the GET having a different id
        > > (track), it refuses to execute because the page == null code.
        > >
        > > The variable of the page needed to be displayed is GET'ed (it's in the
        > > browser URL, and an echo statement in the PHP confirms the value GET'ed,
        > > and lack of the original page id.
        > >
        > > How can I get the code to pass both the page id and the data of the
        > > selected form item at the same time?
        > >
        > > Dariusz
        > >
        > >
        > > The PHP
        > >
        > > <?
        > > if ($_GET['page'] == NULL)
        > > {
        > > echo $_GET['track']; //value passed from the HTML form
        > > echo $_GET['page']; //value of the page id
        > > include ("index2.php ");
        > > }
        > > elseif ($_GET['page'] == index)
        > > {
        > > header ("Location: /index.php");
        > > }
        > > elseif ($_GET['page'] != index)
        > > {
        > > include ("html/".$_GET['page'].".shtml");
        > > }
        > > elseif ($_GET['track'] == a01-t01)
        > > {
        > > include ("html/lyrics/".$_GET['track'].".htm");
        > > }
        > >
        > > ?>
        > >
        > >
        > > The form HTML[/color][/color]

        <FORM method="GET" action="../../index.php" name="myform01" >
        <select name="track">
        <option value="a01-t01" SELECTED>Track 01</option>
        <option value="a01-t02">Track 02</option>
        <option value="a01-t03">Track 03</option>
        <option value="a01-t04">Track 04</option>
        </select>
        <BR><BR>
        <input type="submit" value="Go get the lyrics">
        <input type="hidden" value="<?php print $_GET['page']; ?>" name="page">
        </FORM>



        Mike Bradley
        http://gzen.myhq.info -- free online php tools

        Comment

        Working...