POST problems

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

    POST problems

    Howdy,

    I'm creating a register form which passes some user values to my php file
    using POST

    here's the code:

    form name="register" method="post" action="registe r.php">
    <tr>
    <td>User Name:</td>
    <td><input name="user_id" type="text" value="" size="20"/> </td>
    </tr>

    in my php file I'm trying to get the value of user_id by doing this:

    $user_id = $_POST["user_id"];

    but when I echo $user_id nothing appears so I guess the value isn't be
    passed as I woud expect.

    I'm sur eI'm making a very elementary mistake but I just cannot figure out
    what's wrong?

    Any help much appreciated.

    Thanks




  • frizzle

    #2
    Re: POST problems

    Try the following as a test:

    <?php

    echo $_POST['var'];

    ?>
    <form name="form" method="post" action="<?php echo $PHP_SELF; ?>">
    <input name="var" type="text" id="var">
    <input type="submit" name="Submit" value="Submit">
    </form>


    Your example didn't give any problems here btw.

    Frizzle.

    Comment

    • Ant

      #3
      Re: POST problems

      "frizzle" <phpfrizzle@gma il.com> wrote in message
      news:1130434390 .862233.292660@ f14g2000cwb.goo glegroups.com.. .[color=blue]
      > Try the following as a test:
      >
      >
      > Your example didn't give any problems here btw.
      >
      > Frizzle.
      >[/color]

      Thanks for the reply.

      I did that and got the same error message as with my earlier posted code.


      Comment

      • Ant

        #4
        Re: POST problems

        "frizzle" <phpfrizzle@gma il.com> wrote in message
        news:1130434390 .862233.292660@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > Try the following as a test:
        >
        > Your example didn't give any problems here btw.
        >
        > Frizzle.
        >[/color]

        Thanks for the reply. I tried out your code and got the same error message
        as with my code posted earlier - Undefined index: var in C:\webdev\test. php
        on line 3 - so I guess my php must be broken somehow!! or maybe it's apache
        but it all seems to be working fine. It's been a while since I've worked
        with php and I don't remember altering its settings or anything.

        This is very odd indeed!

        I tested phpinfo() to check and that worked - im using version 5.0.4

        I'm confused as to how I can solve this problem.


        Comment

        • Oli Filth

          #5
          Re: POST problems

          Ant said the following on 27/10/2005 18:23:[color=blue]
          > Howdy,
          >
          > I'm creating a register form which passes some user values to my php file
          > using POST
          >
          > here's the code:
          >
          > form name="register" method="post" action="registe r.php">
          > <tr>
          > <td>User Name:</td>
          > <td><input name="user_id" type="text" value="" size="20"/> </td>
          > </tr>
          >[/color]

          I assume that in reality, your HTML isn't this screwed up?
          [color=blue]
          > $user_id = $_POST["user_id"];
          >
          > but when I echo $user_id nothing appears so I guess the value isn't be
          > passed as I woud expect.
          >[/color]

          What version of PHP are you using? Older than PHP 4.1.0, you need to use
          $HTTP_POST_VARS .

          --
          Oli

          Comment

          Working...