POST problems

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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="register.php">
       <td>User Name:</td>
       <td><input name="user_id" type="text" value="" size="20"/> </td>

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.


Re: POST problems

Try the following as a test:


    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">

Your example didn't give any problems here btw.


Re: POST problems

Quoted text here. Click to load it

Thanks for the reply.

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

Re: POST problems

Quoted text here. Click to load it

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.  

Re: POST problems

Ant said the following on 27/10/2005 18:23:
Quoted text here. Click to load it

I assume that in reality, your HTML isn't this screwed up?

Quoted text here. Click to load it

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


Site Timeline