|
表单的数据插入不到数据库
//database mydb
//table employees
CREATE TABLE employees ( id tinyint(4) DEFAULT '0' NOT NULL
AUTO_INCREMENT, first varchar(20), last varchar(20),
address varchar(255), position varchar(50), PRIMARY KEY (id),
UNIQUE id (id));
//tt.html
<html>
<body>
<form method="post" action="tt.php">
名:<input type="Text" name="first"><br>
姓:<input type="Text" name="last"><br>
住址:<input type="Text" name="address"><br>
职位:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="输入信息">
</form>
</body>
</html>
//tt.php
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees (first,last,address,position)
VALUES ('$first','$last','$address','$position')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
?>
结果是id插入到数据库中
而其他都是空白的 |
|