passing variables between pages

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

    passing variables between pages

    i read a tutorial the other day on passing variables between php pages
    using a html form and setting the action to the php page to parse, can
    anybody see anything wrong with the code below? the problem is, that the
    page always loads the html form, and i cant work out why this is so, even
    after i select a catagory from the drop down list and press search. any1
    have any idea's? TIA.

    the code:

    if (empty($catagor y)) { ?>
    <div align=center>
    <form action="<?php $PHP_SELF ?>" method="GET"> <table>
    <tr> <td>
    <INPUT name=search>
    </td> <td>
    <SELECT NAME=catagory SIZE=1>
    <OPTION any>Search All Catagories
    <OPTION floral>Floral Creations
    <OPTION lighting>Decora tive Lighting
    <OPTION kitchenware>Kit chenware & Crockery <OPTION
    furniture>Fancy Goods & Furniture
    </SELECT>
    </td> <td>
    <INPUT TYPE=submit VALUE="Search">
    </td>
    </form>
    </div>
    <?php exit; }
    echo ("the catagory variable was set");
  • Matthew Robinson

    #2
    Re: passing variables between pages

    just thought i would add, that i cant remember the url of the tutorial,
    and the notes i took didn't include that part for some unknown reason

    Comment

    • Matthew Robinson

      #3
      Re: passing variables between pages

      just thought of checking the url - thats right, so the problem must be in
      my if statement:

      end of url:
      search.php?sear ch=&catagory=Se arch+All+Catago ries

      if statement:

      if (empty($catagor y)) {

      Comment

      • Matthias Esken

        #4
        Re: passing variables between pages

        Matthew Robinson <mattyrobinson6 9@hotmail.com> schrieb:
        [color=blue]
        > <form action="<?php $PHP_SELF ?>" method="GET"> <table>[/color]

        Set your error_reporting to E_ALL, so that PHP will inform you of any
        errors. Then have a look at the resulting source code of the HTML page
        and you should find your error pretty fast. You use $PHP_SELF as a
        function, but what you really want is the value of this variable.
        Additionally I'd suggest that you use $_SERVER['PHP_SELF']. $_PHP_SELF
        will not exist if register_global s is off (which is default since PHP
        4.2.0). So your code should be:

        <form action="<?php echo($SERVER['PHP_SELF'] ?>" method="GET"> <table>
        [color=blue]
        > </td>
        > </form>
        > </div>[/color]

        You forgot to close the table row and the table.

        00:53AM in Germany. I'm going to bed now. :-)

        Regards,
        Matthias

        Comment

        • Pedro Graca

          #5
          Re: passing variables between pages

          Matthew Robinson wrote:[color=blue]
          > search.php?sear ch=&catagory=Se arch+All+Catago ries
          >
          > if (empty($catagor y)) {[/color]

          Read this, _all_ of this




          and follow a few of the links there, too




          a (the usual?) way to do what you want is

          if (empty($_GET['catagory'])) {


          but do not bypass reading the manual :)
          --
          --= my mail box only accepts =--
          --= Content-Type: text/plain =--
          --= Size below 10001 bytes =--

          Comment

          • Matthew Robinson

            #6
            Re: passing variables between pages

            thanks again pedro - i am gonna read the manual now (the link you gave me)

            Comment

            • Matthias Esken

              #7
              Re: passing variables between pages

              Matthew Robinson <mattyrobinson6 9@hotmail.com> schrieb:
              [color=blue]
              > search.php?sear ch=&catagory=Se arch+All+Catago ries
              >
              > if statement:
              >
              > if (empty($catagor y)) {[/color]

              if (isset($_GET['catagory'])) {

              And you might want to change "catagory" to "category". :-)

              Regards,
              Matthias

              Comment

              • Jeffrey Silverman

                #8
                Re: passing variables between pages

                On Thu, 08 Jan 2004 23:34:32 +0000, Matthew Robinson wrote:
                [color=blue]
                > i read a tutorial the other day on passing variables between php pages[/color]

                A lot of on-the-web php tutorials (webmonkey, for example) have gotten out
                of date.

                Look up register_global s()!

                --
                -------------------------
                | Jeffrey Silverman |
                | jeffrey-AT-jhu-DOT-edu|
                -------------------------

                Comment

                Working...