PHP代码不是';t提交到mysql数据库

PHP代码不是';t提交到mysql数据库,php,mysql,Php,Mysql,我正在尝试创建一个网站的登录名。到目前为止,每当我发布到我的数据库时,没有显示提交的信息,唯一发布的就是一个哈希密码 <form method="post" action="submit.php"> <div class="form-group"> <label for="email">Email:</label>

我正在尝试创建一个网站的登录名。到目前为止,每当我发布到我的数据库时,没有显示提交的信息,唯一发布的就是一个哈希密码

<form method="post" action="submit.php">
                        <div class="form-group">
                            <label for="email">Email:</label>
                            <input type="email" class="form-control" id="email">
                        </div>
                        <div class="form-group">
                            <label for="username">Username:</label>
                            <input type="text" class="form-control" id="username">
                        </div>
                        <div class="form-group">
                            <label for="password">Password:</label>
                            <input type="password" class="form-control" id="password">
                        </div>
                        <div class="form-group">
                            <label for="pwd2">Re-Password</label>
                            <input type="password" class="form-control" id="pwd2">
                        </div>
                        <div class="form-group">
                            <input type="submit" class="form-control" id="submit">
                        </div>
                    </form>

电邮:
用户名:
密码:
重新输入密码
提交到这个php块中

<?php
    $servername = "localhost";
    $username = "root";
   $password = "Password";
   $dbname = "DBNAME";


   $email = NULL;
   $user = NULL;
   $pass1 = NULL;

   if (isset($_POST['email'])){
   $email = $_POST['email'];
    }
   if (isset($_POST['username'])){
   $user = $_POST['username'];
   }

    if (isset($_POST['password'])){
   $pass1 = $_POST['password'];
   }
  $hash = password_hash($pass1, PASSWORD_BCRYPT);


   $conn = new mysqli($servername, $username, $password, $dbname);

   if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
   } 

   $sql = "INSERT INTO Users (email, username, password )
   VALUES ('$email', '$user', '$hash')";

   if ($conn->query($sql) === TRUE) {
   echo "New record created successfully";
   } else {
   echo "Error: " . $sql . "<br>" . $conn->error;
    }

  $conn->close();
  ?>

表单字段缺少名称属性。没有它们,就不会向脚本发送任何值。通过执行
var\u导出($\u POST)
可以很容易地测试这一点


电邮:
用户名:
密码:
重新输入密码

仅供参考,您对

非常开放,谢谢,它可以工作,我将开始阻止SQL注入。通过在PHP中使用新的密码功能以及在mysql上使用mysqli,您已经有了一个良好的开端。现在,您已经准备好将其提升到下一个级别,并阻止那些该死的sql注入。
<form method="post" action="submit.php">
    <div class="form-group">
        <label for="email">Email:</label>
        <input type="email" class="form-control" name="email" id="email">
    </div>
    <div class="form-group">
        <label for="username">Username:</label>
        <input type="text" class="form-control" name="username" id="username">
    </div>
    <div class="form-group">
        <label for="password">Password:</label>
        <input type="password" class="form-control" name="password" id="password">
    </div>
    <div class="form-group">
        <label for="pwd2">Re-Password</label>
        <input type="password" class="form-control" name="pwd2" id="pwd2">
    </div>
    <div class="form-group">
        <input type="submit" class="form-control" id="submit">
    </div>
</form>