我的代码将一个空记录插入到MySQL表“table1”中,而不是获取在form1.html中“Name”字段中插入的内容。您有什么想法,为什么它会插入一个空记录,而不是用户在字段中输入的内容?
form1.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"
>
<html lang="en">
<head>
<title>Insert Your Name</title>
</head>
<body>
<h3> Insert Your Name</h3>
<form action="form1.php" method="post">
<input type="text" name="Name">
<input type="Submit" value="Submit" name="Submit">
</form>
</body>
</html>
form.php
> <?php
> $connection =
> mysql_connect("localhost","root","")
> or die ("Couldn't Connect To Server");
> $db = mysql_select_db("db1",
> $connection) or die ("Couldn't Select
> Database"); $query = "CREATE TABLE IF
> NOT EXISTS table1 (Name VARCHAR(20))";
> $result = mysql_query($query) or die
> ("Query Failed: " . mysql_error());
> $query = "INSERT INTO table1 (Name)
> VALUES ('$_post[Name]')"; $result =
> mysql_query($query) or die ("Query
> Failed: " . mysql_error()); $query =
> "SELECT * FROM table1"; $result =
> mysql_query($query) or die ("Query
> Failed: " . mysql_error());
> echo "<TABLE BORDER = '1'>";
> echo "<TR>";
> echo "<TH>Name</TH>";
> echo "</TR>";
>
> while ($row = mysql_fetch_array($result))
> {
> echo "<TR>";
> echo "<TD>", $row['name'], "</TD>";
> echo "</TR>";
> }
> echo "</TABLE>";
> mysql_close($connection); ?>