⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addworker.php

📁 酒店管理系统
💻 PHP
字号:
<?
require_once('../include/connectionadmin.php'); 
include('../include/admin_or_user.php');
require_once('../include/sqlfuns.php');
?>
<? 
if(isset($_POST['add'])&&$_POST['add']=="提交")
{
if(findindb($conn,"name","worker",$_POST['name'],"text"))
{ ?>
<script>
alert("员工已在数据库中!");
window.history.back();
</script>
<? exit; 
}
$insertsql = sprintf("INSERT INTO worker(name,sex,age,payment,address,phone,howlong,hiredate,deptno) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)",
	                   GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['sex'], "text"),
					   GetSQLValueString($_POST['age'], "int"),
					   GetSQLValueString($_POST['payment'], "int"),
					   GetSQLValueString($_POST['address'], "text"),
					   GetSQLValueString($_POST['phone'], "text"),
					   GetSQLValueString($_POST['howlong'], "text"),
                       GetSQLValueString($_POST['hiredate1']."年".$_POST['hiredate2']."月".$_POST['hiredate3']."日", "text"),
					   GetSQLValueString($_POST['deptno'], "int"));
   
$result=odbc_exec($conn,$insertsql);
$go="worker.php";
header("Location: ".$go);
exit;	
  }
 ?>


<!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=gb2312" />
<title>增加员工</title>
<link href="css/hotel.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 36px;
	margin-right: 36px;
}
.STYLE1 {
	color: #FF0000;
	font-size: x-large;
}
.STYLE3 {font-size: 12px}
-->
</style>
<link href="../css/hotel.css" rel="stylesheet" type="text/css" />
</head>
<? require('../include/check.inc');?>
<body>
<table width="100%" border="1">
<tr>
<td>
<div align="center" class="STYLE1">增加员工</div>
<form id="form1" name="form1" method="post" action=""  onSubmit="return (empty(name)&&numbercheck(age)&&numbercheck(payment))">
  <table width="60%" border="0" align="center">
    <tr>
      <td><div align="right">姓&nbsp; 名:</div></td>
      <td><label>
        <input name="name" type="text" id="name" size="15" maxlength="20" />
      *</label></td>
    </tr>
    <tr>
      <td><div align="right">性&nbsp; 别:</div></td>
      <td><label>
        <input type="radio" name="sex" value="男" />
        <img src="../photo/Male.gif" alt="男性" width="23" height="21" />男 
        <input name="sex" type="radio" value="女" checked="checked" />
        <img src="../photo/Female.gif" alt="女性" width="23" height="21" />女</label></td>
    </tr>
    <tr>
      <td><div align="right">年&nbsp; 龄:</div></td>
      <td><label>
        <input name="age" type="text" id="age" size="6" maxlength="6" />
        <span class="STYLE3">(请填入数字)</span></label></td>
    </tr>
   
    <tr>
      <td><div align="right">工&nbsp; 资:</div></td>
      <td><label>
        <input name="payment" type="text" id="payment" size="10" maxlength="10" />
        <span class="STYLE3">(请填入数字)</span></label></td>
    </tr>
    <tr>
      <td><div align="right">电&nbsp; 话:</div></td>
      <td><label>
        <input name="phone" type="text" id="phone" size="20" maxlength="20" />
      </label></td>
    </tr>
    <tr>
      <td><div align="right">部 门:</div></td>
      <td><select name="deptno" id="deptno">
	       <option value="" select="selected">请选择</option> 
	  <? $selectdeptno="select * from dept order by deptno";
	      $deptno= odbc_exec($conn,$selectdeptno);
		  while(odbc_fetch_row($deptno))
		  {
		  ?>
		  <option value="<? echo odbc_result($deptno,'deptno');?> "  ><? echo odbc_result($deptno,'deptname');?></option>
		  <? }?>
	   
	    </select>&nbsp;</td>
    </tr>
    <tr>
      <td><div align="right">雇用日期:</div></td>
      <td><label>
      <select name="hiredate1" id="hiredate1">
        <option value="1984">1984</option>
		<? $i=1978;
		    $year=date("Y");
		    while($i<=$year){ ?>
			 <option value="<? echo $i;?>"><? echo $i;?></option>
			 <? $i++; }?>
      </select>
      <select name="hiredate2" id="hiredate2">
        <option value="1" selected="selected">1</option>
		<? $i=2;
		    while($i<=12){ ?>
			 <option value="<? echo $i;?>"><? echo $i;?></option>
			 <?  $i++;  }?>
      </select>
      <select name="hiredate3" id="hiredate3">
        <option value="1">1</option>
		<? $i=2;
		    while($i<=31){ ?>
			 <option value="<? echo $i;?>"><? echo $i;?></option>
			 <?  $i++; }?>
      </select>
      日</label></td>
    </tr>
    <tr>
      <td><div align="right">雇用年限:</div></td>
      <td><label>
        <input name="howlong" type="text" id="howlong" size="10" maxlength="10" />
      </label></td>
    </tr>
    <tr>
      <td><div align="right">地&nbsp; 址:</div></td>
      <td><label>
        <input name="address" type="text" id="address" size="49" maxlength="60" />
      </label></td>
    </tr>
  </table>
  <p align="center">
    <label>
    <input name="add" type="submit" id="add" value="提交" />
    </label>
    <label>
    <input name="reset" type="reset" id="reset" value="重置" />
    </label>
  </p>

</form>
<div align="center"><a href="worker.php">返回</a></div>
</td>
</tr>
</table>
<p \>
 <script src="../copyright.inc">
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -