$_GET and $_POST superglobals are empty, but shouldn't be

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chrispclay
    New Member
    • Aug 2007
    • 2

    $_GET and $_POST superglobals are empty, but shouldn't be

    Hi, i am having problems with using superglobals. I have been trying to use the $_GET and $_POST superglobals but no matter which one i use, it doesn't print out anything. It doesn't print out what i am trying to reach from a form. Is it something to do with my php.ini file? I have read somewhere that it is something to do with the register_global s part but am still not sure. Is there something i should do to enable these superglobals? Any help would be much appreciated, Thanks Chris
  • abertay
    New Member
    • Jul 2007
    • 10

    #2
    would you mind if i ask you post your code here...

    That way i can help you more quickly...

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, Chris. Welcome to TSDN!

      Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

      $_GET and $_POST will only contain values if you are sending GET or POST variables, respectively.

      To populate $_GET, you will need to append your variables to the query string. For example:
      Code:
      http://localhost/path/to/your/script.php?variable=value
      If you then call this code in script.php:
      [code=php]
      print_r($_GET);
      [/code]

      You will see this:
      Code:
      Array
      (
          [variable] => value
      )
      Populating $_POST generally requires submitting a form.

      For more information, have a look at this document.

      Comment

      • MarkoKlacar
        Recognized Expert Contributor
        • Aug 2007
        • 296

        #4
        What version on PHP are you using?
        Can you post the begining of the <form>-tag and the PHP-code?

        Comment

        • chrispclay
          New Member
          • Aug 2007
          • 2

          #5
          Hi yea sorry,

          On my HTML page my code is . . .
          [code=html]
          <form action="calcula te.php" method="POST">
          <p><strong> Input First Integer: </strong></p>
          <input type="text" name="Integer_o ne">
          <p><input type="submit" value="send"/></p>
          </form>
          [/code]
          Then linked from this is a php document with the following code . . . .
          [code=php]
          <?php
          echo $_POST['Integer_one'];
          ?>
          [/code]
          Last edited by Atli; Sep 2 '07, 02:23 PM. Reason: Added [code] tags

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Chris.

            Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Originally posted by chrispclay
              Hi yea sorry,

              On my HTML page my code is . . .
              [code=html]
              <form action="calcula te.php" method="POST">
              <p><strong> Input First Integer: </strong></p>
              <input type="text" name="Integer_o ne">
              <p><input type="submit" value="send"/></p>
              </form>
              [/code]
              Then linked from this is a php document with the following code . . . .
              [code=php]
              <?php
              echo $_POST['Integer_one'];
              ?>
              [/code]
              Hi.

              I see no problem with that code. Under normal circumstances that code should print out the value you entered in the <input> box called 'Integer_one'.
              That is, of course, assuming that the PHP code is in the file called 'calculate.php' .

              If this isn't working... Are you sure you are not receiving any errors? Check out this thread to be absolutely sure.

              Comment

              Working...