将用户数据从输入字段输入到我的 MySQL 表时遇到了一些问题。这是代码。任何帮助表示赞赏。
<form action="login.php" method="post">
First Name: <input type="text" name="name" /> <br />
Last Name: <input type="text" name="lName" /> <br />
Email: <input type="email" name="email" /> <br />
Username: <input type="text" name="uName" /> <br />
Password: <input type="password" name="pw" /> <br />
<input type="submit" name="register" />
</form>
<br>
<form action="login.php">
Already have an account?
<input type="submit" value="Login Here" />
</form>
</div>
<?php
if (isset($_POST["register"])){
$name = $_POST["name"];
$lName = $_POST["lName"];
$email = $_POST["email"];
$uName = $_POST["uName"];
$pw = $_POST["pw"];
$db = new mysqli($servername, $username, $password, $database, $dbport);
$sql = "INSERT INTO users VALUES (null, $name, $lname, $email, $uName, $pw, null)";
$result = mysqli_query($db, $sql);
}
?>