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