I can't get this simple code to work (IT.php):

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

(action.php):

Hi <?php echo $POST["name"]; ?>.
You are <?php echo $
POST["age"]; ?> years old.

The output is: Hi . You are years old.

I turned register_globals to both on and off but there was no effect.

The strange thing about this is a few days ago it was working fine, but now it doesnt work.

Could it be a problem with my browser? I installed some anti pop-up software could that have changed some settings somewhere?

Any help would be appreciated.

    I don't see anything wrong in your code, but you should have register_globals off that's for default in the lateste version of PHP and everytime you made a modification to php.ini you should restart apache if you run php inside apache, you can try with $_HTTP_POST_VARS too, maybe that array work. Hope that helps you.

    Hector

    http://www.oksonora.com

      i dont ever use the post method. instead, i use the get method. so remove the method="POST" from your form tag and on action.php change the 2 post methods to GET.

      chud

        Don't even worry about setting your Post to get, thats the default in HTML so doesn't need to be done, I think i read that somewhere anyway. Oh well, that was a useless piece of information, sorry for taking up your time... lol

          thats why i told him to remove the method=post in his form tag because it needs to be method=get... but thats not required. 🙂

          but you still need to change your post to get in the action file so php knows.

          chud

            Try this:
            Hi <?php echo "$POST[name]"; ?>.
            You are <?php echo "$
            POST[age]"; ?> years old.

              This is how I would do:

              <?php
              
              if($QUERY_STRING == "result")
              {
              echo "Hi $name. ";
              echo "You are $age years old.";
              }
              else
              {
              echo "<form action=\"?result\" method=\"post\">\n";
              echo "Your name: <input type=\"text\" name=\"name\" /><br>\n";
              echo "Your age: <input type=\"text\" name=\"age\" /><br>\n";
              echo "<input type=\"submit\" value=\"Send\">\n";
              echo "</form>\n";
              }
              ?>
              

              But that's just me...

                Write a Reply...