HTML表单不能与图像提交按钮一起使用? [英] HTML form not working with image submit button?
问题描述
< html>
< head>
< link href =style.css =stylesheettype =text / css>
< / head>
< form action =test1.phpenctype =multipart / form-datamethod =POST>
< input type =hiddenname =playnovalue =testing>
< input type =imagesrc =uploads / defb.pngname =submitvalue =submit/>
< / form>
< / html>
以下内容保存在test1.php中:
<?php
$ hiddenvalue = $ _POST ['playno'];
if(isset($ _ POST ['submit'])){
echoOK;
}
else
{
echoerror;
}
?>
在broswer中,当我打印$ hiddenvalue时,返回值testing。然而,每次输出错误的时候,都不是OK。
我非常感谢任何帮助。这让我疯狂!
非常感谢。
input type =image / code>,浏览器发送 submit_x
和 submit_y
。
所以在PHP中, $ _ POST ['submit']
将不可用,但 $ _ POST ['submit_x'] 和 $ _ POST ['submit_y']
将被定义(包含点击图像的X / Y坐标)。
I have the following html form i am testing out.
<html>
<head>
<link href = "style.css" rel = "stylesheet" type = "text/css">
</head>
<form action = "test1.php" enctype = "multipart/form-data" method = "POST">
<input type = "hidden" name = "playno" value = "testing">
<input type = "image" src = "uploads/defb.png" name = "submit" value = "submit"/>
</form>
</html>
The following is saved in "test1.php":
<?php
$hiddenvalue = $_POST['playno'];
if (isset($_POST['submit'])){
echo "OK";
}
else
{
echo "error";
}
?>
In the broswer i am returned the value "testing" when i print $hiddenvalue. However each and every time it outputs "error" as well, not "OK".
I would greatly appreciate any help. It is driving me mad!!!
Many thanks in advance.
解决方案 When using a input type="image"
, the browser sends submit_x
and submit_y
.
So in PHP, $_POST['submit']
will not be available, but $_POST['submit_x']
and $_POST['submit_y']
will be defined (containing the X/Y coordinates where the image was clicked on).
这篇关于HTML表单不能与图像提交按钮一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!