首页 > 解决方案 > 使用 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" 的字段中检索值

标签: php

解决方案


问题是您忘记在输入标签中添加“=”

改变

<input name"phone" type="number">
<input name"email" type="email">

<input name="phone" type="number">
<input name="email" type="email">

推荐阅读