469,323 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

$_POST is empty (in MSIE?)

G'day,

has any of You ever experienced the problem that posted forms deliver an
empty $_POST-array?

I have a form like:

<form method="POST" action="https://.../result.html?qid=70">
<input type="checkbox" value="1" name="1a">
<input type="checkbox" value="1" name="1b">
(...)
<input type="submit" name="Answer" value="Answer">
</form>

and every once in a while I get empty results (1 out of 10, maybe). This
only happens in MSIE 6.0, as far as I can see, but I'm not absolutely sure.
Some users have the problem all the time, some never.

I use https to connect and mod_rewrite to rewrite "result.html" to
"result.php"...

SERVER_SOFTWARE:
Apache/1.3.27 (Unix) PHP/4.3.1 mod_ssl/2.8.12 OpenSSL/0.9.6g

Beats me ... help _very_ appreciated.

Rudi
Jul 17 '05 #1
13 5372
Rudolf Horbas wrote:
G'day,
Thank you, g'night :)
every once in a while I get empty results (1 out of 10, maybe). This
only happens in MSIE 6.0, as far as I can see, but I'm not absolutely sure.
Some users have the problem all the time, some never.


I guess it happens when there is no info to POST *and* the user
does not click the submit button but presses ENTER instead.

This also happens with Mozilla Firebird. I tested with:

<?php
echo <<<HTML
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="checkbox" name="chk1" value="1" checked/>box 1<br/>
<input type="checkbox" name="chk2" value="2"/>box 2<br/>
<input type="submit" name="submit" value="Go!"/>
</form>
HTML;
if (isset($_POST)) {
echo "<pre>\n\n\n"; print_r($_POST); echo '</pre>';
}
?>

==> uncheck box 1 (with the mouse) and press ENTER
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
> Thank you, g'night :)

It's night over here, too :-)
I guess it happens when there is no info to POST *and* the user
does not click the submit button but presses ENTER instead.
(...)


I'm afraid that's not the problem. The users have _definitely_ checked
some boxes.
I also have a <hidden>-field that does not get through.

$_POST gets lost somewhere in cyberspace ...

*sigh*
Rudi
(off to bed)
Jul 17 '05 #3
I noticed that Message-ID: <c1**********@svr7.m-online.net> from Rudolf
Horbas contained the following:
I have a form like:

<form method="POST" action="https://.../result.html?qid=70">
<input type="checkbox" value="1" name="1a">
<input type="checkbox" value="1" name="1b">
(...)
<input type="submit" name="Answer" value="Answer">
</form>


Can't help with the intermittent thing but while I was checking this out
I was lazy (I have register_globals on) and wrote this

<form method="POST" action="<?php print $PHP_SELF; ?>">
<input type="checkbox" value="1" name="1a">
<input type="checkbox" value="1" name="1b">
<input type="submit" name="Answer" value="Answer">
</form>
<?php
print $1a;
print $1b;
?>

Doesn't work. Gives a parse error. However...

<form method="POST" action="<?php print $PHP_SELF; ?>">
<input type="checkbox" value="1" name="a1">
<input type="checkbox" value="1" name="b1">
<input type="submit" name="Answer" value="Answer">
</form>
<?php
print $a1;
print $b1;
?>

Works without fail.

It suggests to me that there may be an issue with the naming of your
checkboxes.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Attribute values of type ID and NAME must begin with a letter in the range
A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens
("-"), underscores ("_"), colons (":"), and periods ("."). These values are
case-sensitive

Louise

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:pr********************************@4ax.com...
I noticed that Message-ID: <c1**********@svr7.m-online.net> from Rudolf
Horbas contained the following:
I have a form like:

<form method="POST" action="https://.../result.html?qid=70">
<input type="checkbox" value="1" name="1a">
<input type="checkbox" value="1" name="1b">
(...)
<input type="submit" name="Answer" value="Answer">
</form>


Can't help with the intermittent thing but while I was checking this out
I was lazy (I have register_globals on) and wrote this

<form method="POST" action="<?php print $PHP_SELF; ?>">
<input type="checkbox" value="1" name="1a">
<input type="checkbox" value="1" name="1b">
<input type="submit" name="Answer" value="Answer">
</form>
<?php
print $1a;
print $1b;
?>

Doesn't work. Gives a parse error. However...

<form method="POST" action="<?php print $PHP_SELF; ?>">
<input type="checkbox" value="1" name="a1">
<input type="checkbox" value="1" name="b1">
<input type="submit" name="Answer" value="Answer">
</form>
<?php
print $a1;
print $b1;
?>

Works without fail.

It suggests to me that there may be an issue with the naming of your
checkboxes.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #5
I noticed that Message-ID:
<c1*************@ID-210679.news.uni-berlin.de> from boclair contained
the following:
Attribute values of type ID and NAME must begin with a letter in the range
A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens
("-"), underscores ("_"), colons (":"), and periods ("."). These values are
case-sensitive


There ya go...

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
OhmygodIshouldaknownthat...

Thanks Geoff & Louise!

(Obviously most browsers still handle these kind of values, but it's
MSIE that conforms to the standards ...)

Rudi
Jul 17 '05 #7
Geoff Berrow wrote:
(...)
boclair wrote:
Attribute values of type ID and NAME must begin with a letter in the range
A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens
("-"), underscores ("_"), colons (":"), and periods ("."). These values are
case-sensitive

There ya go...


Darn, I was so glad when I read what I thought was the solution ...
But then noticed that I had just stripped the name attribute for better
reading ... My name attributes are really correct and are named like
"antw1a", etc ...

The whole setup is like:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<!-- <form method="POST" action="result.html?fid=67">
this is the receiving script, but we might aswell use
PHP_SELF:
-->
<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
Question 1<br />
answer1.a <input type="checkbox" value="1" name="antw1a"><br />
answer1.b <input type="checkbox" value="1" name="antw1b"><br />
Question 2:<br />
answer2.a <input type="checkbox" value="1" name="antw2a"><br />
answer2.b <input type="checkbox" value="1" name="antw2b"><br />
<input type="hidden" name="fid" value="67">
<input type="submit" name="Answer" value="Answer">
</form>
<pre>
<?php
print_r ( $_POST );
?>
</pre>
<?php

// This is what happens in the receiving script:
reset( $_POST );
$fields = "";
$values = "";

while ( list ( $key, $val ) = each( $_POST ) )
{
// get only answer checkboxes:
if ( preg_match ( "/^antw[0-9]+[a-z].*/", $key ) )
{
// build sql-string:
$fields .= "`$key`,\n";
$values .= "'$_POST[$key]',\n";
}
}

// other form data:
$fields .= "`fid`,\n";
$values .= "'$fid',\n";

$fields .= "`date`\n";
$values .= "'" . date ("Y-m-d H:i:s") . "'\n";
$sql = "INSERT INTO `tablename` ($fields) VALUES ($values)";

//$result = mysql_query($sql, $connect);
echo "<pre>$sql</pre>";
?>
</body>
</html>

In my .htaccess I have:
# not that I really need it, but to be sure ...
php_value register_globals 1

RewriteEngine on
RewriteRule ^(.*)\.html foodir/$1.php [nocase]

As already mentioned, in most cases everything is fine. I have had more
than 1.000 submits without problems, but every once in a while,
someone's $_POST is empty. What's more: This usually happens to the same
people. The last guy I had was on XP, MSIE 6.0, .NET installed, Cookies
on (I use $_SESSION). He never managed to submit one single form with
any data.

Could https be a problem, in a way that it sometimes "eats" up POST data?

Aw, while thinking that much aloud, Google brought up the solution on
"POST https problem":
http://www.phparch.com/discuss/index...372/0#msg_2372
and, linked from there:
http://support.microsoft.com/default.aspx?kbid=831167
<cite>
SYMPTOMS
Programs that use Wininet functions to post data (such as a user name or
a password) to a Web server retry the POST request with a blank header
if the Web server closes (or resets) the initial connection request.
</cite>

I guess that's it: a bug in MSIE.

Now I'll have to see if I can handle this on the server (MS gives some
hints: increase HTTP keep-alive timeout interval). Otherwise the users
will get a hint to update ...

*sigh*

Greetings & thanks for Your feedback,
Rudi
Jul 17 '05 #8
On Wed, 25 Feb 2004 00:16:37 +0100, Rudolf Horbas <rh*****@gmx.net>
wrote:
G'day,

has any of You ever experienced the problem that posted forms deliver an
empty $_POST-array?
<snip>
and every once in a while I get empty results (1 out of 10, maybe). This
only happens in MSIE 6.0, as far as I can see, but I'm not absolutely sure.
Some users have the problem all the time, some never.


Not personally, but this sounds like a problem that I read about
somewhere within the last week or two. I think it was in
comp.lang.perl.misc. It's an IE error which crops up when certain
combinations of patches are applied. You might try Googling on the
archive for that group.

--
Stephen Poley
Jul 17 '05 #9
I noticed that Message-ID: <c1**********@svr7.m-online.net> from Rudolf
Horbas contained the following:
As already mentioned, in most cases everything is fine. I have had more
than 1.000 submits without problems, but every once in a while,
someone's $_POST is empty. What's more: This usually happens to the same
people. The last guy I had was on XP, MSIE 6.0, .NET installed, Cookies
on (I use $_SESSION). He never managed to submit one single form with
any data.


Something to do with XP perhaps? Wouldn't surprise me

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #10
Stephen Poley wrote:
On Wed, 25 Feb 2004 00:16:37 +0100, Rudolf Horbas <rh*****@gmx.net>
wrote:
(..)
and every once in a while I get empty results (1 out of 10, maybe). This
only happens in MSIE 6.0, as far as I can see, but I'm not absolutely sure.
Some users have the problem all the time, some never.

Not personally, but this sounds like a problem that I read about
somewhere within the last week or two. I think it was in
comp.lang.perl.misc. It's an IE error which crops up when certain
combinations of patches are applied. You might try Googling on the
archive for that group.


Thanks, the problem is clear now (thanks to Google).
See Message-ID: <c1**********@svr7.m-online.net>

Rudi
Jul 17 '05 #11
Geoff Berrow wrote:
Something to do with XP perhaps? Wouldn't surprise me


Not quite. It's MSIE 6.0 with a certain security update, and the client
side solution is another MSIE patch ...
http://support.microsoft.com/default.aspx?kbid=831167

I suppose that the server-side solution that MS suggests ("Increase HTTP
keep-alive timeout interval") is not really a solution, because You only
decrease the probability that the error happens.

My forms are lengthy multiple-choice questionnaires for medical
education, and some users might dwell some reasonable time on them.

Damn, I mean, program server-side because we don't depend on any
clients, right?

XP is not so bad after all ... at least it's _a_lot_ better than 98 ...

Rudi
Jul 17 '05 #12
Geoff Berrow wrote:
Something to do with XP perhaps? Wouldn't surprise me

Not quite. It's MSIE 6.0 with a certain security update, and the client
side solution is another MSIE patch ...
http://support.microsoft.com/default.aspx?kbid=831167

I suppose that the server-side solution that MS suggests ("Increase HTTP
keep-alive timeout interval") is not really a solution, because You only
decrease the probability that the error happens.

My forms are lengthy multiple-choice questionnaires for medical
education, and some users might dwell some reasonable time on them.

Damn, I mean, program server-side because we don't depend on any
clients, right?

XP is not so bad after all ... at least it's _a_lot_ better than 98 ...

Rudi
Jul 17 '05 #13
Geoff Berrow wrote:
Something to do with XP perhaps? Wouldn't surprise me

Not quite. It's MSIE 6.0 with a certain security update, and the client
side solution is another MSIE patch ...
http://support.microsoft.com/default.aspx?kbid=831167

I suppose that the server-side solution that MS suggests ("Increase HTTP
keep-alive timeout interval") is not really a solution, because You only
decrease the probability that the error happens.

My forms are lengthy multiple-choice questionnaires for medical
education, and some users might dwell some reasonable time on them.

Damn, I mean, program server-side because we don't depend on any
clients, right?

XP is not so bad after all ... at least it's _a_lot_ better than 98 ...

Rudi
Jul 17 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Jack | last post: by
7 posts views Thread by Dan | last post: by
5 posts views Thread by lorenzdominic_ | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.