答案 0 :(得分:1)
首先,您需要创建mysql connection。并将代码更改为此代码。
<?php
$con = mysqli_connect("localhost", "root", "", "my_db"); //create connection
if(isset($_POST['submit']))
{
$name = $_POST['fullname'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$sql = "INSERT INTO users (name, username, email, password) VALUES ('$name', '$username', '$email', '$password')";
$result = mysqli_query($con, $sql);
}
?>
<form action="" method="post">
<div class="field-wrap">
<label>
Name<span class="req">*</span>
</label>
<input name="fullname" type="text" required autocomplete="off" />
</div>
<div class="field-wrap">
<label>
Username<span class="req">*</span>
</label>
<input name="username" type="text" required autocomplete="off" />
</div>
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input name="email" type="text" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Set A Password<span class="req">*</span>
</label>
<input name="password" type="password" required autocomplete="off"/>
</div>
<button type="submit" class="button button-block"/>Create Account</button>
</form>
答案 1 :(得分:0)
尝试使用此
$sql = "INSERT INTO `users` (`name`, `username`, `email`, `password`) VALUES ('$name', '$username', '$email', '$password')";