I just installed PHP on my Windows Server 2000, and the PHP is parsing fine, but it can't seem to find variables.

Forms which post to a response page, or query strings in URLs don't get recognized on the result page.

For example, submitting a form with a input field

( <INPUT TYPE="text" NAME="UserName">)

is submitted to results.php, but when I try to use $UserName, it says:

Notice: Undefined variable: UserName

What am I missing (perhaps in the .ini file)?

This even fails when I enter results.php?UserName=Jon

Thanks,

Jon 😕

    try using $POST[UserName] or $POST['UserName'] instead...

      14 days later

      I have been experiencing the same problem (w/ Win2K, Apache 1.3.4, PHP 4.2.3). I have tried the solution provided, but still have the same problem.

      Here are two code samples (based on "SAMS Teach Yourself PHP in 24 Hours (or die trying))"

      "php3a.php" looks like this:

      <html>
      <head>
      <title>PHP test</title>
      </head>
      <body>
      <form action="php3b.php">
      <p>User:
      <input type="text" name="user"></p>
      <br>
      <p>Address:
      <textarea name="address" rows="5" cols="40">
      </textarea></p>
      <br>
      <input type="submit" value="Submit!">
      </form>
      </body>
      </html>

      and "php3b.php" looks like this:

      <html>

      <head>
      <title>PHP test</title>
      </head>
      <body>
      <?php
      print $POST['user']; (also tried "$user")
      print $
      POST['address'];
      foreach ($GLOBALS as $key=>$value ) {
      print "\$GLOBALS[\"$key\"] == $value<br>";
      }
      ?>
      </body>
      </html>

      (I added the $GLOBALS output for some debugging. It seems to indicate that the POST data is not reaching PHP.

      Results:...

      Notice: Undefined index: user in d:\program files\apache group\apache\htdocs\php3b.php on line 12

      Notice: Undefined index: address in d:\program files\apache group\apache\htdocs\php3b.php on line 13
      $GLOBALS["HTTP_POST_VARS"] == Array
      $GLOBALS["POST"] == Array
      $GLOBALS["HTTP_GET_VARS"] == Array
      $GLOBALS["
      GET"] == Array
      $GLOBALS["HTTP_COOKIE_VARS"] == Array
      $GLOBALS["COOKIE"] == Array
      $GLOBALS["HTTP_SERVER_VARS"] == Array
      $GLOBALS["
      SERVER"] == Array
      $GLOBALS["HTTP_ENV_VARS"] == Array
      $GLOBALS["ENV"] == Array
      $GLOBALS["HTTP_POST_FILES"] == Array
      $GLOBALS["
      FILES"] == Array
      $GLOBALS["_REQUEST"] == Array
      $GLOBALS["GLOBALS"] == Array
      $GLOBALS["key"] == GLOBALS
      $GLOBALS["value"] == GLOBALS

      Any assistance os greatly appreciated.

        Whoops, didn't see this and made another thread.

        I am encountering the same problem on XP HE, Apache 1.3 and PHP4. I didnt notice the problem with the POST method, but when I tried to set variables in the URL (index.php?op=blah) it doesn't read them. And returns the Warning: $op is not set. or whatever.

          When I place phpinfo() in the page I call, the variables are displayed, either using a GET or POST.

          GET["user"] user

          GET["address"] this is a test

          POST["user"] yser

          POST["address"] this is a test

            Indeed it does! Thank you very much.

              When searching for some answers to this problem, I did find it curious that most hits on the same subject were dated quite recently.

              Learning that the new release contained one change to how POST and GET variables are set - and that this "breaks" a lot of code - explains much.

              But (as in my case) it plays heck with us PHP newbies who are learning from a book and do not necessarily understand the ramifications of a one-line change in a config file.

              Perhaps there is sufficient commentary in the INI file (I don't have it in front of me right now), but making this more obvious to those floudering would be beneficial.

              I don't intend this to be a criticism, just an observation.

                Write a Reply...