0

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.

4

3 回答 3

2

使用 时input type="image",浏览器会发送submit_xsubmit_y

所以在 PHP 中,$_POST['submit']将不可用,但$_POST['submit_x']$_POST['submit_y']被定义(包含单击图像的 X/Y 坐标)。

于 2013-02-03T00:04:58.507 回答
1

只需在表单中添加以下内容:

<input type="hidden" name="submit" value="submit"/>

以便它$_POST['submit']在您的 PHP 中接收。

于 2014-07-25T23:51:29.673 回答
-1
<input type = "image" src = "uploads/defb.png"  name = "submit" value = "submit"/>

改成:

<input type = "submit"  name = "submit" value = "submit"/>

因为输入 didint 有这种类型

为输入 HTML 创建样式

<input type = "submit"  name = "submit" value = "submit" id="button" />

CSS

#button {

background:url("uploads/defb.png");
border:0;
outline:0;

}
于 2013-02-03T00:00:16.523 回答