variable chopped when using POST method, but not GET :?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gratou
Forum Newbie
Posts: 10
Joined: Sun Jul 28, 2002 4:27 am
Location: Auckland, NZ

variable chopped when using POST method, but not GET :?

Post by gratou »

I am totally at lost with this one.

When I change from using GET to using POST, the last character of the value typed in the single variable in my form gets chopped off.

I dumped the $GLOBALS and $_POST arrays and they contain the same truncated value.

GET transmits it with no loss. Any idea?

Thank you!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Could you post the code you've been using. Some info about your setup might be useful too, ie. which version of PHP, which OS, which webserver.

On a side note, please check before you start a new topic which forum you're in because I not too sure what this has to do with databases...

Mac
gratou
Forum Newbie
Posts: 10
Joined: Sun Jul 28, 2002 4:27 am
Location: Auckland, NZ

Oooops!

Post by gratou »

Sorry, please delete the thread, I'll ask in the right place.
:oops:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

No it's ok I've already moved it :) . I really should have said that, sorry.

Mac
gratou
Forum Newbie
Posts: 10
Joined: Sun Jul 28, 2002 4:27 am
Location: Auckland, NZ

Continued

Post by gratou »

Thank you for moving it. :D

My code is very straight forward:
- a form with method="post"
- a field called Userid
- a submit button

When I read the value returned in my PHP script, it is truncated if post is used, not with get.

Something else is changed: if I type a < character in the field, it is left alone by get, but post changes it to %3 (truncation of %3C, the code for <). Strange hey?

I am using PHP 4.2.1 on W98.
gratou
Forum Newbie
Posts: 10
Joined: Sun Jul 28, 2002 4:27 am
Location: Auckland, NZ

Please!!

Post by gratou »

Please people, I am sure one of you has an idea. Please...
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

can u post the code?
gratou
Forum Newbie
Posts: 10
Joined: Sun Jul 28, 2002 4:27 am
Location: Auckland, NZ

Post by gratou »

Here is the code, but I think you'll be disappointed:

HTML

Code: Select all

<form action="&#123;$PHP_SELF&#125;" method="post">
  <tr><td valign="top" >Login:      </td>
      <td><input name="Userid" id="Userid" maxlength="16" size="16">
PHP

Code: Select all

while (list($name,$value) = each($_GET)) &#123;echo "ggggggget $name=$value<br>\n";&#125;
while (list($name,$value) = each($_POST)) &#123;echo "ppppppp $name=$value<br>\n";&#125;
changing the form's method means the _post and _get arrays' contents change. Except the _POST array contains a truncated $Userid variable.

This is probably something to do with PHP's (or apache's?) setup as I discovered even phpmyadmin is crippled and doesn't pass parameters right (database names get truncated).

Thanks again very much for your insight.
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

Try removing the maxlength on your text field, it might also be something to do with the browser...
gratou
Forum Newbie
Posts: 10
Joined: Sun Jul 28, 2002 4:27 am
Location: Auckland, NZ

Post by gratou »

:?

I just reinstalled the whole of php and it now works. :D

Thank you all.
Post Reply