|
Posted by maraguida on 12/10/05 04:09
Sergei Riaguzov wrote:
> Consider a test:
>
> wtf.html:
>
> === Cut ===
> <form action="eh.php" method="POST">
> <input type="checkbox" name="many spaces and. . dots. . "/>
Spaces are not allowed in the name of HTML elements.
<quote src="http://www.w3.org/TR/html4/types.html#h-6.2">
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").
</quote>
> <input type="submit" value="Submit">
> </form>
> === Cut ===
>
> eh.php:
>
> === Cut ===
> <?php
> print_r($_POST);
> ?>
> === Cut ===
>
> When we check the checkbox and click the Sumbit button we will see:
>
> Array ( [many_spaces_and____dots____] => on )
Yes, here also.
> It is send to server normally:
>
> many+spaces+and.+.+dots.+.+=on
Yes, here also.
> but in $_POST (or $HTTP_POST_VARS) we see what we see. Any ideas?
I understand the reason the spaces are converted but I do not know why
the points are replaced; you may wnat to try the following if you need
the NAME with the dots and the spaces:
wtf.php (not wtf.html)
=== Cut ===
<form action="eh.php" method="post">
<input type="checkbox" name="<?php echo base64_encode('many spaces
and. . dots. . '); ?>"/>
<input type="submit" value="Submit">
</form>
=== Cut ===
eh.php
=== Cut ===
<?php
print_r($_POST);
$X_POST = array();
foreach ($_POST as $k=>$v) {
$X_POST[base64_decode($k)] = $v;
}
$_POST = $X_POST;
unset($X_POST);
echo "\n\n================\n\n";
print_r($_POST);
?>
=== Cut ===
Navigation:
[Reply to this message]
|