我已经尝试调试这个很久了,不明白为什么它不向我的数据库发送数据。另外作为一个指示,我正在使用 Boostrap 并且此表单位于模态框内。有人可以帮帮我吗?我将包括我的 html 片段以及 php 代码。
代码
<form class="form-horizontal" role="form" action="register.php" method="POST">
<div class="input-group margin-bottom-sm"><span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span> <input class="form-control" type="text" name="fname" id="FirstName" placeholder="First Name" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="lname" id="LastName" placeholder="Last Name" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="dob" id="dob" placeholder="Date of Birth" required>
</div><br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-book" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="school" id="SchoolName" placeholder="School" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span>
<input class="form-control" type="text" name="username" id="Username" placeholder="Username" required>
</div></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></span>
<input class="form-control" type="password" name="pass" data-minlenght= "6" id="Pass" placeholder="Password" required>
</div><div class="help-block">Minimum of 6 characters</div></br></br>
<div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></span>
<input class="form-control" type="password" id="inputPasswordConfirm" data-match="#inputPassword"
data-match-error="Whoops, these don't match" placeholder="Confirm" required>
</div></br>
<div class="form-group">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" id="register">Sing Up</button>
</div>
</form>
PHP
<?php
$conn=mysqli_connect("localhost","mydatabase","mypassword")
or die("Could not connect:".mysqli_error($conn));
mysqli_select_db($conn , 'mydatabase') or die ('Database will not open');
if(isset($_POST['register'])){
$fname = ($_POST['FirstName']);
$lname = ($_POST['LastName']);
$dob = ($_POST['dob']);
$school = ($_POST['SchoolName']);
$username = ($_POST['Username']);
$pass = ($_POST['Pass']);
$query = "INSERT INTO users (FirstName,LastName,dob,SchoolName,Username,Pass)VALUES('$FirstName','$LastName','$Username','$dob', '$SchoolName','$Pass',)";
$result = mysqli_query($conn,$query);
}
?>