For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > October 2005 > POST problems









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author POST problems
Ant

2005-10-27, 6:57 pm

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="register.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

2005-10-27, 6:57 pm

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.

Ant

2005-10-27, 6:57 pm

"frizzle" <phpfrizzle@gmail.com> wrote in message
news:1130434390.862233.292660@f14g2000cwb.googlegroups.com...
> Try the following as a test:
>
>
> Your example didn't give any problems here btw.
>
> Frizzle.
>


Thanks for the reply.

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


Ant

2005-10-27, 6:57 pm

"frizzle" <phpfrizzle@gmail.com> wrote in message
news:1130434390.862233.292660@f14g2000cwb.googlegroups.com...
> Try the following as a test:
>
> Your example didn't give any problems here btw.
>
> Frizzle.
>


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 as to how I can solve this problem.


Oli Filth

2005-10-27, 6:57 pm

Ant said the following on 27/10/2005 18:23:
> 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="register.php">
> <tr>
> <td>User Name:</td>
> <td><input name="user_id" type="text" value="" size="20"/> </td>
> </tr>
>


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

> $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.
>


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

--
Oli
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com