<html>
<head><title>员工信息表</title></head>
<center>
<h1>员工信息表</h1>
<form method="POST" action="add_html.php">
id :<input type="text" name="txtid"><br>
姓名 :<input type="text" name="txtname"><br>
所属部门:<input type="text" name="txtdept"><br>
出生日期:<input type="text" name="txtbirth"><br>
入职时间:<input type="text" name="txttime">
</form>
<input type="submit" name="ok" value="提交">
<input type="reset" value="重填"></center>
</html>
<?php
include "mysqlconnect.php";
if(isset($_POST['ok']))
{
$id=$_POST['txtid'];
$name=$_POST['txtname'];
$dept=$_POST['txtdept'];
$birth=$_POST['txtbirth'];
$time=$_POST['txttime'];
$sql="insert into zy(id ,姓名,所属部门,出生日期,入职时间) values($id,'$name','$dept',$birth,$time)";
$res=mysql_query($sql);
if($res)
{
echo "<script> alert('数据库添加成功');</script>";
echo "<script>window.location.href='showList.php'</script>";
}
else
{
echo "<script> alert('添加失败');</script>";
}
}
mysql_close($myline);
?>
10 回答

大大大大鹿眸
TA贡献1条经验 获得超1个赞
<input type="submit" name="ok" value="提交">
把这段的value=“ok”才行,这样他的值才是ok
if(isset($_POST['ok']))
你这段才会执行,如果你不改value你应该写成if(isset($_POST['提交']))才是
- 10 回答
- 1 关注
- 2662 浏览
添加回答
举报
0/150
提交
取消