Forum Moderators: coopster

Message Too Old, No Replies

Getting submitted variables

         

Kronos

4:22 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



Hi,

when I use POST to get the data from a Form, I don't get the data on the other side and I don't know why. Could anyone help me with my problem? Thanks!

Here's an example of what I do:

//FORM.HTML

<form name="form1" method="post" action="test.php">
<input name="user" type="text" id="user">
<input type="submit" name="Submit" value="Submit">
</form>

//TEST.PHP

$user=$_POST['user'];
echo $user;

coopster

4:31 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You're not giving much to go on here, but the code snippet looks OK. Do you have two separate documents here (FORM.HTML and TEST.PHP)? If so, are they located in the same directory (root, by the looks of it) of your web server?

Timotheos

4:34 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could be your version of php. If it's before 4.1.0 then use $HTTP_POST_VARS.

Kronos

5:56 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



Well,

there are two files in the same directory (root of the web server) and the code I posted is the only code in the file. It's only a test file...

jatar_k

6:22 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try using print_r [ca2.php.net]($_POST);
to see if there is any data in the POST array

Knowles

10:32 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



I have had issues recently with case of the values...
ie:
<form name="form1" method="post" action="test.php">
for me had to be
<form name="form1" method="POST" action="test.php">

Yes I know it shouldnt matter and it sounds odd. But it did on a few scripts. That was the only thing I changed between tries and it fixed it.

vincevincevince

4:37 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i put those code snippets you gave exactly into files on my server and they worked fine.

PHP Version 4.2.2
Windows NT 5.1 build 2600
register_globals Off
safe_mode Off

[
_SERVER["GATEWAY_INTERFACE"] CGI/1.1
_SERVER["SERVER_PROTOCOL"] HTTP/1.1
_SERVER["REQUEST_METHOD"] POST
]

Why not try using $_REQUEST[user'] or the HTTP_GET as above? Or try putting both parts in one file for the test.

Kronos

6:51 pm on Aug 1, 2003 (gmt 0)

10+ Year Member



Yeah, thanks everyone. Finally, Timotheos was right. My version was lower than 4.1.0, which is why the way I did it didn't work. It worked with HTTP_POST_VARS. Thanks everyone!

Timotheos

7:12 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Frustrating isn't it? I only thought of it cuz I went through the same thing.

Kronos

7:17 pm on Aug 1, 2003 (gmt 0)

10+ Year Member



Let's just say I won't make THAT mistake twice :)

jatar_k

7:42 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I won't make THAT mistake twice

none of us have yet but we've all done it once :)