Form Variables gone missing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • david_ffm@mail.com

    #1

    Form Variables gone missing

    Hi Guys,

    hope I'm on-topic here - couldn't find any leads with a search so
    maybe someone has an idea.

    I've got a PHP form that is supposed to set some variables from
    its fields and then call itself by the POST method.

    Here is e.g. a minimal test version called "top.php":-

    #!/usr/bin/php
    Content-type: text/html

    <HTML>

    Welcome <?php echo $_POST["name"]; ?>.<br />
    You are <?php echo $_POST["age"]; ?> years old! <br>
    Welcome <?php echo $name; ?>.<br />
    You are <?php echo $age; ?> years old! <br>

    <form action="top.php " method="POST">
    Enter your name: <input type="text" name="name" />
    Enter your age: <input type="text" name="age" />
    <input type="submit" />
    </form>

    <? phpinfo(); ?>

    </HTML>

    When I enter data in the fields name or age, it just gets ignored,
    goes missing, thrown away by PHP. The first 4 lines that should
    output this info show that the variables are all blank.

    The phpinfo() call at the end shows me clearly that register_global s
    is on.

    The only way I've found so far is with the GET method - there the
    expected arrays and variables are also broken,
    but $_SERVER["REQUEST_UR I"] is correctly set (yipee!) and so
    I can parse that myself - sort of defeats the point of PHP though.

    What could be the problem here?
    Is there some other setting I'm missing?
    This stuff all worked without a hitch in PHP3 - has something
    else been broken in the name of security?

    TIA,
    David

  • David Johnstone

    #2
    Re: Form Variables gone missing

    BTW sorry about the anon post.
    Also I meant to say I have
    PHP 4.4.0 (cli) (built: Nov 17 2005 20:26:48)
    running on SuSe 10 kernel 2.6.13-15-default
    David

    Comment

    • ZeldorBlat

      #3
      Re: Form Variables gone missing

      Why do you have #!/usr/bin/php at the top of your script? Are you
      running this from the command line or through a webserver?

      Comment

      • David Johnstone

        #4
        Re: Form Variables gone missing

        ZeldorBlat wrote:[color=blue]
        > Why do you have #!/usr/bin/php at the top of your script? Are you
        > running this from the command line or through a webserver?[/color]

        Both really, the command line only to test for syntax errors etc.,
        but both return an error if this line is not present.

        I'm using Apache 2.0.54 and it returns an Internal Error (500)
        if this is not present. Do you think there is a problem with
        my server configuration?

        David

        Comment

        • Sean

          #5
          Re: Form Variables gone missing

          You need to integrate php into apache by using mod php. You can test
          for syntax errors by logging them and/or printing the error to the
          screen, or using the -l option with the php binary.

          Comment

          • David Johnstone

            #6
            Re: Form Variables gone missing

            Sean wrote:[color=blue]
            > You need to integrate php into apache by using mod php. You can test
            > for syntax errors by logging them and/or printing the error to the
            > screen, or using the -l option with the php binary.[/color]

            Hi Sean,
            thanks - I think my problem must be in that area.
            I thought I had already done that though.
            Under yast - Network Services - http Server the PHP4 module is
            installed and enabled. Isn't that enough? Do I have to also manually
            make some entries in the config file?
            Also, if mod php is not installed, why is httpd executing my files at
            all? Shouldn't it in that case just be serving text and html files and
            not executing anything?
            Most puzzling.

            Comment

            • Sean

              #7
              Re: Form Variables gone missing

              David Johnstone wrote:[color=blue]
              > Sean wrote:[color=green]
              > > You need to integrate php into apache by using mod php. You can test
              > > for syntax errors by logging them and/or printing the error to the
              > > screen, or using the -l option with the php binary.[/color]
              >
              > Hi Sean,
              > thanks - I think my problem must be in that area.
              > I thought I had already done that though.
              > Under yast - Network Services - http Server the PHP4 module is
              > installed and enabled. Isn't that enough? Do I have to also manually
              > make some entries in the config file?[/color]

              You have to edit some things in the httpd config file. Goto here if you
              are using linux
              http://php.mirrors.esat.net/manual/e...ix.apache2.php, or here
              http://php.mirrors.esat.net/manual/en/install.unix.php and choose your
              install guide.
              [color=blue]
              > Also, if mod php is not installed, why is httpd executing my files at
              > all? Shouldn't it in that case just be serving text and html files and
              > not executing anything?[/color]

              Its executing because you have this: #!/usr/bin/php.

              You will not be able access from variables; you will not have access to
              sessions, etc... When you have mod php working then remove that line
              #!/usr/bin/php.
              [color=blue]
              > Most puzzling.[/color]

              Comment

              • Sean

                #8
                Re: Form Variables gone missing

                Also if you think mod_php is installed and set up correctly, e.g.

                LoadModule php4_module modules/libphp4.so & this AddType
                application/x-httpd-php .php is in your httpd conf file, then just
                remove #!/usr/bin/php and try it.

                Comment

                • David Johnstone

                  #9
                  Re: Form Variables gone missing

                  Thanks Sean, that all sounds logical.
                  I guess my mistake was trusting yast to do what it said it had
                  done rather than editing the config files myself. Wouldn't be the
                  first time a gui setup has put a spanner in the works.
                  I've now installed xampp, which has a preconfigured apache,
                  php, mysql etc, and newer versions - and there it all works
                  fine. As you say, the difference seems to be the LoadModule
                  entry in httpd.conf - with this knowledge I may try and test
                  the old installation again.
                  Thanks again, David

                  Sean wrote:[color=blue]
                  > Also if you think mod_php is installed and set up correctly, e.g.
                  >
                  > LoadModule php4_module modules/libphp4.so & this AddType
                  > application/x-httpd-php .php is in your httpd conf file, then just
                  > remove #!/usr/bin/php and try it.[/color]

                  Comment

                  • Sean

                    #10
                    Re: Form Variables gone missing

                    If it aint broke don't fix it.

                    Comment

                    Working...