如何检索输入类型中输入的数据="数字"?

时间:2015-03-08 02:06:13

标签: php html string post input

如果这是我的HTML四分之一

<!DOCTYPE html>
<head>
<title>qrFileONEZES</title>
</head>
<body>
<form action="delFourm.php" method="post">


Enter the position 1 - 20 of which to delete at:

 <input type="number" size="6" name="Delete at pos? :" min="1" max="20" value="1"><br>
<br><br>
<input type="submit" name="submit2" value="enterz">

</form>
</body>
</html>

然后将我重定向到另一个文件delFourm.php,其中:

<?php

.
.
.


if (isset($_POST['submit2']))
{
    $numToDel = $_POST['Delete at pos? :']; // this is the num to del from qrFile?
    // echo "this is my test to see if value is sent? " . $numToDel;
}
else
{
echo "num wasnt obtained?";
}

echo "the number is " . $numToDel;
.
.
.
?>

为什么输出的$numToDel输出空白?

使用echo时,我没有得到任何输出,我想在此文件的后续代码段中引用从前一个论坛中选择的数字。我的编码技能很差,所以详细解释会有所帮助。

2 个答案:

答案 0 :(得分:4)

  

ID和NAME令牌必须以字母([A-Za-z])开头,后面可以跟任意数量的字母,数字([0-9]),连字符(&#34; - &#34 ;),下划线(&#34; _&#34;),冒号(&#34;:&#34;)和句号(&#34;。&#34;)。

将输入的名称更改为:name="delete_at_post"

<!DOCTYPE html>
<head>
<title>qrFileONEZES</title>
</head>
<body>
<form action="delFourm.php" method="post">


Enter the position 1 - 20 of which to delete at:

 <input type="number" size="6" name="delete_at_post" min="1" max="20" value="1"><br>
<br><br>
<input type="submit" name="submit2" value="enterz">

</form>
</body>
</html>
你的delFourm.php中的

<?php

if (isset($_POST['submit2']))
{
    $numToDel = $_POST['delete_at_post']; // this is the num to del from qrFile?
    // echo "this is my test to see if value is sent? " . $numToDel;
}
else
{
echo "num wasnt obtained?";
}

echo "the number is " . $numToDel;

?>

您可以阅读如何设置名称属性:

  

http://www.w3.org/TR/html401/types.html#type-cdata

答案 1 :(得分:1)

我通过在HTML中使用它来实现它的工作

other type test for input: <input type="number" name="numm" min="1" max="20"><br>

而不是:

 <input type="number" size="6" name="delete_at_post" min="1" max="20" value="1"><br>



不确定为什么它不起作用,而不是重要。