gpt4 book ai didi

php - 如何检索输入类型 ="number"输入的数据?

转载 作者:行者123 更新时间:2023-12-02 04:23:04 26 4
gpt4 key购买 nike

如果这是我的 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;

?>

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

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

关于php - 如何检索输入类型 ="number"输入的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28922313/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com