我正在调试一个php脚本,我已经把它缩小到:
index.php:
<html>
<body>
<?php
$id = "42";
echo "<form action="handle_data.php" method="post">";
echo "<input type="image" src="my_button.png" name="id" value="$id">";
echo "</form>";
?>
</body>
</html>
_
handle_data.php:
<?php
echo 'PHP Input:<br />';
echo file_get_contents('php://input');
echo '<br />';
echo 'Post variables:<br />';
print_r($_POST);
?>
在Mac或ios设备上使用Safari效果良好:
PHP Input:
id.x=108&id.y=83&id=42
Post variables:
Array ( [id_x] => 108 [id_y] => 83 [id] => 42 )
但是,使用Win7与IE8或Firefox 17,发布的数据'42'丢失=/
PHP Input:
id.x=128&id.y=96
Post variables:
Array ( [id_x] => 128 [id_y] => 96 )
为什么,为什么?
根据这个博客,Firefox和IE正在遵循HTML5标准。它提供了一个CSS替代方案。
将input
元素更改为:
<input type='submit' name='id' value='$id' class='mySubmit' />
和添加CSS:
input.mySubmit {
border: none;
cursor: pointer;
display: inline-block;
text-indent: -3000px;
background: url(my_button.png) no-repeat 50% 50%;
width: 50px;
height: 20px;
}