LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 551|回复: 3

表单的数据插入不到数据库

[复制链接]
发表于 2003-8-16 20:24:01 | 显示全部楼层 |阅读模式
表单的数据插入不到数据库


//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插入到数据库中
而其他都是空白的
发表于 2003-8-17 12:19:59 | 显示全部楼层
关于php与mysql的很好的例子和教程----phpbbs。

从中可以学到用php语言操作mysql的很多很多。建议你找来看看。
发表于 2003-8-17 21:40:55 | 显示全部楼层
改一下表单变量获取方法:
$fist=$_POST['fist']
 楼主| 发表于 2003-8-20 20:15:13 | 显示全部楼层

现在好了

现在好了
是global的问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表