我创建了以下代码,以便将html表单提供的某些数据输入到我的数据库中。我使用phpmyadmin中的wamp创建了数据库,并将其命名为库
以下代码位于文件名“ insert.php”中:
<?php include 'dbconfig.php';?>
<!DOCTYPE HTML PUCLIC "-//W3C//DTDHTML
4.0 Transitional//EN"><HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="style.css">
</HEAD>
<div class="navbar">
<a href="mydatabase.php">Home</a>
<a href="insert.php">Insert</a>
<a href="update.php">Update</a>
<a href="delete.php">Delete</a>
</div>
<br><br>
<div class="navbar">
<a href="insert.php">Member</a>
<a href="book.php">Book</a>
<a href="author.php">Author</a>
</div>
<?php
if(isset($_POST['sumbit']))
{
$sql = "INSERT INTO member (memberID, MFirst, MLast,Street,number,postalCode,Mbirthdate)
VALUES ('".$_POST["memberID"]."','".$_POST["MFirst"]."','".$_POST["MLast"]."','".$_POST["Street"]."','".$_POST["number"]."',
'".$_POST["postalCode"]."','".$_POST["Mbirthdate"]."')";
$result = mysqli_query($conn,$sql);
}
?>
<FORM METHOD="post" ACTION="insert.php">
<div class="input-group">
<label>Member Id</label>
<INPUT TYPE="text" name="memberID" SIZE="30">
</div>
<div class="input-group">
<label>First Name</label>
<INPUT TYPE="text" name="MFirst" SIZE="30">
</div>
<div class="input-group">
<label>Last Name<label>
<INPUT TYPE="text" name="MLast" SIZE="30">
</div>
<div class="input-group">
<label>Street Name</label>
<INPUT TYPE="text" name="Street" SIZE="30">
</div>
<div class="input-group">
<label>Street Number</label>
<INPUT TYPE="number" name="number" min=0 SIZE="30">
</div>
<div class="input-group">
<label>Postal Code</label>
<INPUT TYPE="number" name="postalCode" min=0 SIZE="30">
</div>
<div class="input-group">
<label>Birth Day</label>
<INPUT TYPE="date" name="Mbirthdate" SIZE="30">
</div>
<button class="btn" TYPE="submit" name="submit">Submit Info </button>
<button class="btn" TYPE="reset" name="Reset">Reset </button>
</FORM>
</HTML>
这是在dbconfig.php中:
<?php
$conn=mysqli_connect("localhost","root","","library");
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
?>
上面的代码是通过查看其他类似我的问题而制作的。但是我似乎无法弄清楚为什么,输入的内容不会进入数据库中的表“ member”。我该怎么解决?