[英]Code working in Chrome, Firefox and Safari but not in IE or Opera
[英]Code working in Chrome but not in Firefox
以下代码适用于Chrome。 但在Firefox中,提交步骤无效
<?php
if(!isset($_POST['submit'])){
?>
<form action="" method="post">
<b>ID:</b>
<input name="std_no" type="text" />
<input type="image" width="100" value="submit" name="submit" id="submit" src="images/butup.gif" alt="submit Button">
</form>
<?php
}
else {
$id=$_POST['std_no'];
echo $id;
}
?>
问题是图像提交不发送名称“submit”,它发送“submit_x”和“submit_y”
所以你应该检查一下
if (isset($_POST['submit_x']))...
编辑:我已经做了一点测试,它出现在Firefox(16)和IE(7,8,9)只有x和y发送,而在Chrome(23)和Safari(5.1)它也发送名字也与x和y一起。
所以最安全的方法是检查值是: isset($_POST['name_x'])
<?php
if(!isset($_POST['submit'])){
$id=$_POST['std_no']; // put it here so whenever you click submit button
echo $id; // $_POST is trigger
?>
<form action="/**input action**/" method="post">
<b>ID:</b>
<input name="std_no" type="text" />
<input type="image" width="100" value="submit" name="submit" id="submit" src="images/butup.gif" alt="submit Button">
</form>
你应该输入action=""; // the php page of your code or the page where you want to get the data sample page.php
action=""; // the php page of your code or the page where you want to get the data sample page.php
或试试这个
<?php echo htmlentities($_SERVER['PHP_SELF']); ?> // put in action
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.