如何检索输入类型 ="number" 中输入的数据?
How to retrieve data entered in input type ="number"?
如果这是我的 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 时没有得到任何输出,我想在这个文件后面的代码段中引用从上一个论坛中选择的数字。我的编码能力很差,所以详细的解释会有所帮助。
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
将您输入的名称更改为: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;
?>
您可以阅读如何设置名称属性:
我通过在 HTML fourm
中使用它来工作
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>
不确定为什么它不起作用,但这并不重要。
如果这是我的 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 时没有得到任何输出,我想在这个文件后面的代码段中引用从上一个论坛中选择的数字。我的编码能力很差,所以详细的解释会有所帮助。
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
将您输入的名称更改为: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;
?>
您可以阅读如何设置名称属性:
我通过在 HTML fourm
中使用它来工作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>
不确定为什么它不起作用,但这并不重要。