求助各位大佬,帮忙看看这两段代码,为啥在操作页面的时候,无法将数据插入数据库中,其他表都可以
页面设计部分
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="inc/css.css" type="text/css" />
</head>
<body>
<form name="form1" method="post" action="empAction.php?act=insert" enctype="multipart/form-data">
<table width="98%" border=0 align=center cellpadding=2 cellspacing=1 bordercolor="#799AE1" class=tableBorder>
<tbody>
<tr>
<th align=center colspan=16 style="height: 23px">员工信息录入</th>
</tr>
<tr bgcolor="#DEE5FA">
<td colspan="16" align="center" class=txlrow> </td>
</tr>
<tr height="30" align="center" bgcolor="#799AE1">
<td width="14%" align="right" class=txlHeaderBackgroundAlternate><a style="color:#F00">*</a> 姓名:</td><td align=left class=txlrow><input type="text" style="padding-left:5px; width:140px;" name="eName" /><span style="padding-left:50px; color:#FFF">提示:带 * 为必填项</span></td>
<td width="10%" align="right" class=txlHeaderBackgroundAlternate><a style="color:#F00">*</a> 性别:</td><td align=left class=txlrow><input type="radio" style="padding-left:5px; width:30px;" name="eSex" value="1" checked="checked" />男<input type="radio" style="padding-left:5px; width:30px;" name="eSex" value="2" />女</td>
</tr>
<tr height="30" align="center" bgcolor="#799AE1">
<td align="right" class="txlHeaderBackgroundAlternate"><a style="color:#F00">*</a>编号:</td>
<td align="left" class="txlrow"><input name="eId" type="text" id="eId" style="padding-left:5px; width:140px;" /></td>
<td align="right" class=txlHeaderBackgroundAlternate> </td>
<td align=left class=txlrow> </td>
</tr>
<tr height="30" align="center" bgcolor="#799AE1">
<td width="14%" align="right" class=txlHeaderBackgroundAlternate> 出生日期:</td> <td align=left class=txlrow><input type="text" style="padding-left:5px; width:140px;" name="eBirthday" /><span style="padding-left:50px; color:#FFF">格式:1993-09-08</span></td>
<td width="10%" align="right" class=txlHeaderBackgroundAlternate> 籍贯:</td>
<td align=left class=txlrow><input type="text" style="padding-left:5px; width:120px;" name="eNative" /><span style="padding-left:10px; color:#FFF">例:云南省昆明市</span></td>
</tr>
<tr height="30" align="center" bgcolor="#799AE1">
<td width="14%" align="right" class=txlHeaderBackgroundAlternate><a style="color:#F00">*</a> 学历:</td> <td align=left class=txlrow><input type="text" style="padding-left:5px; width:140px;" name="eEdu" /></td>
<td width="10%" align="right" class=txlHeaderBackgroundAlternate> 入职日期:</td>
<td align=left class=txlrow><input type="text" style="padding-left:5px; width:120px;" name="eDate" /><span style="padding-left:10px; color:#FFF">格式:2015-09-08</span></td>
</tr>
<tr height="30" align="center" bgcolor="#799AE1">
<td width="10%" align="right" class=txlHeaderBackgroundAlternate><a style="color:#F00">*</a> 所属部门:</td>
<td align=left class=txlrow>
<select name="dId" style="width:150px;">
<option value="0" >请选择部门</option>
<{foreach $rs as $val}>
<option value="<{$val.dId}>"><{$val.dName}></option>
<{/foreach}>
</select></td>
<td width="14%" align="right" class=txlHeaderBackgroundAlternate><a style="color:#F00">*</a> 在职状态:</td> <td align=left class=txlrow><input type="radio"
<?php
include ("upload.class.php");
include ("configs/config.php");
$act=$_GET["act"];
if($act=="insert"){
$eName=$_POST["eName"];
$eSex=$_POST["eSex"];
$eBirthday=$_POST["eBirthday"];
$eNative=$_POST["eNative"];
$eEdu=$_POST["eEdu"];
$eDate=$_POST["eDate"];
$eJob=$_POST["eJob"];
$eNdate=$_POST["eNdate"];
$eTel=$_POST["eTel"];
$eQQ=$_POST["eQQ"];
$eExp=$_POST["eExp"];
$eTec=$_POST["eTec"];
$dId=$_POST["dId"];
$eId=$_POST["eId"];
$sql="select * from emp";
$rs=$db->fetchAll($sql);
foreach($rs as $key=>$val){
if($eName==$val["eName"]){
?>
<script type="text/javascript">
alert("员工姓名已存在,添加失败");
window.location="empAdd.php";
</script>
<?php
exit;
}
if($eTel==$val["eTel"]){
?>
<script type="text/javascript">
alert("员工电话重复,添加失败");
window.location="empAdd.php";
</script>
<?php
exit;
}
if($eQQ!=false){
if($eQQ==$val["eQQ"]){
?>
<script type="text/javascript">
alert("员工QQ号码重复,添加失败");
window.location="empAdd.php";
</script>
<?php
exit;
}
}
}
$eImg=$_FILES["eImg"];
$uI=new upload($eImg);
$uRlimg=$uI->main();
if($eName!=false && $eSex!=false && $eEdu!=false && $eTel!=false && $dId!=0){
$sql="insert into emp values('{eId}','{$eName}','{$eSex}','{$eEdu}',{$eJob},'{$eDate}','{$eNdate}','{$eTel}','{$eQQ}','{$uRlimg}','{$eTec}','{$eExp}','{$dId}','{$eBirthday}','{$eNative}')";
$db->query($sql);
?>
<script type="text/javascript">
alert("添加员工信息成功");
window.location="emplist.php";
</script>
<?php
}else{
?>
<script type="text/javascript">
alert("请完善带*信息再提交");
window.location="empAdd.php";
</script>
<?php
}
}else if($act=="delete"){
$eId=$_GET["eId"];
$sql="select * from emp where eId={$eId}";
$rs=$db->fetchOne($sql);
$fileeimg=$rs["eImg"];
if(is_file($fileeimg)){
unlink($fileeimg);
}
$sql_d="delete from emp where eId={$eId}";
$db->query($sql_d);
?>
<script type="text/javascript">
alert("成功删除了该员工的信息资料");
window.location="emplist.php";
</script>
<?php
}else if($act=="update"){
$eId=$_GET["eId"];
$eName=$_POST["eName"];
$eBirthday=$_POST["eBirthday"];
$eNative=$_POST["eNative"];
$eSex=$_POST["eSex"];
$eEdu=$_POST["eEdu"];
$eDate=$_POST["eDate"];
$eJob=$_POST["eJob"];
$eNdate=$_POST["eNdate"];
$eTel=$_POST["eTel"];
$eQQ=$_POST["eQQ"];
$eExp=$_POST["eExp"];
$eTec=$_POST["eTec"];
$dId=$_POST["dId"];
$sql="select * from emp";
$rs=$db->fetchAll($sql);
foreach($rs as $key=>$val){
if($eId!=$val["eId"]){
if($eName==$val["eName"]){
?>
<script type="text/javascript">
alert("员工姓名已存在,修改失败");
window.location="updateemp.php?eId=<?php echo $eId ?>";
</script>
<?php
exit;
}
if($eTel==$val["eTel"]){
?>
<script type="text/javascript">
alert("员工电话重复,修改失败");
window.location="updateemp.php?eId=<?php echo $eId ?>";
</script>
<?php
exit;
}
if($eQQ!=false){
if($eQQ==$val["eQQ"]){
?>
<script type="text/javascript">
alert("员工QQ号码重复,修改失败");
window.location="updateemp.php?eId=<?php echo $eId ?>";
</script>
<?php
exit;
}
}
}
}
$eImg=$_FILES["eImg"];
//判断是否有新图修改
if(strlen($eImg["eImg"])>0){
//有新图
//删除原图
$sql_0="select * from emp where eId={$eId}";
$rs_0=$db->fetchOne($sql_0);
$fileeimg=$rs_0["eImg"];
if(is_file($fileeimg)){
unlink($fileeimg);
}
//上传新图
$uI=new upload($eImg);
$uRlimg=$uI->main();
if($eName!=false && $eSex!=false && $eEdu!=false && $eTel!=false){
$sql="update emp set eName='{$eName}',eSex={$eSex},eBirthday='{$eBirthday}',eNative='{$eNative}',eEdu='{$eEdu}',eTel='{$eTel}',eDate='{$eDate}',eJob={$eJob},eNdate='{$eNdate}',eQQ='{$eQQ}',eExp='{$eExp}',eTec='{$eTec}',eImg='{$uRlimg}',dId={$dId} where eId={$eId}";
$db->query($sql);
?>
<script type="text/javascript">
alert("修改成功");
window.location="emplist.php";
</script>
<?php
}else{
?>
<script type="text/javascript">
alert("带*的为必填项");
window.location="updateemp.php?eId=<?php echo $eId ?>";
</script>
<?php
}
}else{
$sql_1="select eImg from emp where eId={$eId}";
$rs_1=$db->fetchOne($sql_1);
$uRlimg=$rs_1["eImg"];
if($eName!=false && $eSex!=false && $eEdu!=false && $eTel!=false){
$sql="update emp set eName='{$eName}',eSex={$eSex},eBirthday='{$eBirthday}',eNative='{$eNative}',eEdu='{$eEdu}',eTel='{$eTel}',eDate='{$eDate}',eJob={$eJob},eNdate='{$eNdate}',";
$sql.="eQQ='{$eQQ}',eExp='{$eExp}',eTec='{$eTec}',eImg='{$uRlimg}',dId={$dId} where eId={$eId}";
$db->query($sql);
?>
<script type="text/javascript">
alert("修改成功");
window.location="emplist.php";
</script>
<?php
}else{
?>
<script type="text/javascript">
alert("带*的为必填项");
window.location="updateemp.php?eId=<?php echo $eId ?>";
</script>
<?php
}
}
}