php - 使用 type="number" 检索输入的值
问题描述
我的 HTML 代码
<html>
<head>
</head>
<body>
<form action="process.php" method="post">
<lable>Name</lable>
<input name="name" type="text">
<lable>Phone</lable>
<input name"phone" type="number">
<lable>Email</lable>
<input name"email" type="email">
<input type="submit" name="submit">
</form>
</body>
</html>
我的 PHP 代码
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
echo "Welcome dear $name to our website, <br>";
echo "Your phone number is $phone and your email ID is $email";
}
?>
我在这里做错了什么?Veeraj · 讲座 36 · 2 小时前
输出是
欢迎亲爱的 Keerthi 访问我们的网站 您的电话号码是,您的电子邮件 ID 是
我无法在 type="number" 和 type="email" 的字段中检索值
解决方案
问题是您忘记在输入标签中添加“=”
改变
<input name"phone" type="number">
<input name"email" type="email">
到
<input name="phone" type="number">
<input name="email" type="email">
推荐阅读
- java - 服务器 UNIX 时间和设备当前时间的差异
- android - 有条件地使用选项卡式活动
- javascript - Liferay/AlloyUI:覆盖 util.js 或禁用表单焦点滚动
- javascript - 如何让新代码运行
- java - 为什么 MySQL JDBC 不使用“开始事务”查询来开始事务?
- python - Python docx:获取插入/删除/修改的段落/元素
- kotlin - 将 Akka Route TestKit 与 Kotlin Spek 一起使用
- python - 如何使用 matplotlib 子图垂直拉伸图形
- c# - GoToUrl() 挂起
- javascript - mapbox-gl js 对“文本偏移”使用阶梯斜坡