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

📄 sysuser.php

📁 酒店管理系统
💻 PHP
字号:
<?
require_once('../include/connectionadmin.php'); 
include('../include/admin_or_user.php');
require_once('../include/sqlfuns.php');
?>
<?
if(isset($_POST['adduser'])&&$_POST['adduser']=="提交")
{ 
if(findindb($conn,"name","user",$_POST['name'],"text"))
{ ?>
<script>
alert("此用户已被使用!");
window.history.back();
</script>
<? exit; 
}
$insetsql=sprintf("insert into user(name,password,userlevel,deptno) values(%s,%s,%s,%s)",
 GetSQLValueString($_POST['name'],'text'),
 GetSQLValueString(md5($_POST['password']),'text'),
 GetSQLValueString($_POST['userlevel'],'text'),
 GetSQLValueString($_POST['deptno'],'int'));
odbc_exec($conn,$insetsql);
}
?>
<?
 
if(isset($_POST['s'])&&$_POST['s']=="提交")
{ 
if($_POST['name']!=$_POST['oldname'])
if(findindb($conn,"name","user",$_POST['name'],"text"))
{ ?>
<script>
alert("此用户已被使用!");
window.history.back();
</script>
<? exit; 
}
$updatesql=sprintf("update user set name=%s,password=%s,userlevel=%s,deptno=%s where name=%s",
 GetSQLValueString($_POST['name'],'text'),
 GetSQLValueString(md5($_POST['password']),'text'),
 GetSQLValueString($_POST['userlevel'],'text'),
 GetSQLValueString($_POST['deptno'],'int'),
 GetSQLValueString($_POST['oldname'],'text')
                  );
$t=odbc_exec($conn,$updatesql);
$msg=<<<HERE
<script>
alert("修改成功");
location='sysuser.php';
</script>
HERE;
if($t)
echo $msg;
}
?>
<?
if(isset($_GET['detele'])&&$_GET['detele']=="1")
{ 

$detelesql=sprintf("delete from user where id=%s",
 GetSQLValueString($_GET['userid'],'int'));
  odbc_exec($conn,$detelesql);
  }


$selectsql="select * from user left join dept on user.deptno=dept.deptno order by user.deptno,user.userlevel";
$result=odbc_exec($conn,$selectsql);
?>





<!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;
}
.STYLE2 {color: #FF0000}
-->
</style></head>
<? require('../include/check.inc');?>

<script>
function func(a)
{
  if(a.value==4)
     document.all.user.innerHTML="";
}
</script>
<body>
<? if(!isset($_GET['adduser'])) {?>
<table width="100%" border="1">
  <tr>
    <td width="25%"><div align="center">用户名</div></td>
    <td width="25%"><div align="center">部门</div></td>
    <td width="25%"><div align="center">用户角色</div></td>
    <td width="25%"><div align="center">操作</div>      <div align="center"></div></td>
  </tr>
  <? while(odbc_fetch_row($result)) { ?>
  <tr>
    <td><div align="center"><? echo odbc_result($result,'name');?></div></td>
    <td><div align="center"><? echo odbc_result($result,'deptname');?>&nbsp;</div></td>
    <td><div align="center">
      <? if( odbc_result($result,'userlevel')=='admin') { echo "<span class=STYLE2>";echo "管理员"; echo "</span>";}else echo "操作员";?>
    &nbsp;</div></td>
    <td><div align="center"><a href="?modefiy=1&userid=<? echo odbc_result($result,'id');?>#modefiy1">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;   <a href="?detele=1&userid=<? echo odbc_result($result,'id');?>" onClick="return comfiy()">删除</a></div></td>
  </tr>
  <? }?>
</table>
<p>
  <label>
  <input type="submit" name="Submit2" value="增加系统用户" onClick="location='?adduser=1'" />
  </label>
</p>

<? 
}

if(isset($_GET['modefiy'])&&isset($_GET['userid'])&&$_GET['modefiy']==1&&!isset($_POST['s'])) 
   {
   $selectuser="select * from user where id=".$_GET['userid'];
   $result1=odbc_exec($conn,$selectuser);
   ?>
<a name="modefiy1" id="modefiy1"></a>
<table width="100%" border="1">
<tr>
<td>
   <form action="sysuser.php" method="post" name="form" id="form" onSubmit="return (equal(password,repassword)&&empty(password)&&empty(deptno))">
     <table width="100%" border="0">
       <tr>
         <td>&nbsp;</td>
         <td class="STYLE2">&nbsp;</td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td class="STYLE2">修改系统使用者</td>
       </tr>
       <tr>
         <td heigth="6"></td>
         <td></td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       </tr>
       <tr>
         <td><div align="right">用 户 名:</div></td>
         <td><label>
           <input name="name" type="text" id="name" size="20" maxlength="20" value="<? echo odbc_result($result1,'name');?>"/>
         *</label></td>
       </tr>
       <tr>
         <td><div align="right">密  码:</div></td>
         <td><label>
           <input name="password" type="password" id="password" size="20" maxlength="20" />
         *</label></td>
       </tr>
       <tr>
         <td><div align="right">重复密码:</div></td>
         <td><label>
           <input name="repassword" type="password" id="repassword" size="20" maxlength="20" />
         *</label></td>
       </tr>
       <tr>
         <td><div align="right">用户角色:</div></td>
         <td>
		 <span id="user">
		 <label>
           <input name="userlevel" type="radio" value="user" <? if(odbc_result($result1,'userlevel')=="user") {?>checked="checked" <? }?>/>
           操作员
		   </label>
		   </span>
		   <label>
           <input type="radio" name="userlevel" value="admin" <? if(odbc_result($result1,'userlevel')=="admin") {?>checked="checked" <? }?> />
         管理员</label></td>
       </tr>
       <tr>
         <td><div align="right">部 门:</div></td>
         <td><label>
           <select name="deptno" id="deptno" onChange="func(this)">
		   <? $selectdept="select * from dept order by deptno";
		       $deptno=odbc_exec($conn,$selectdept);
			   while(odbc_fetch_row($deptno))
			   { ?>
             <option value="<? echo odbc_result($deptno,'deptno');?>" 
			 <? if(odbc_result($result1,'deptno')==odbc_result($deptno,'deptno'))
			     {?>
			  selected="selected" 
			  <? }?>
			  ><? echo odbc_result($deptno,'deptname');?></option>
			 <? } ?>
             </select>
         </label></td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       </tr>
       <tr>
         <td><label>
         </label></td>
         <td><label>
          &nbsp;<input name="s" type="submit" id="s" value="提交" />   
         &nbsp;  
         <input type="reset" name="Submit" value="重置" />
         <input name="oldname" type="hidden" id="oldname" value="<? echo odbc_result($result1,'name');?>" />
         </label></td>
       </tr>
	   <tr>
	     <td>&nbsp;</td>
	     <td>&nbsp;</td>
       </tr>
	   <tr>
	     <td>&nbsp;</td>
	     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="sysuser.php">返回</a></td>
       </tr>
	   <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       </tr>
     </table>
</form>
</td>
</tr>
</table>
<? }

if(isset($_GET['adduser'])&&$_GET['adduser']==1)
{
?>
<table width="100%" border="1">

<tr>
<td>
<form action="sysuser.php" method="post" name="form1" id="form1" onSubmit="return (equal(password,repassword)&&empty(password)&&empty(deptno))">
     <table width="60%" border="0">
       <tr>
         <td>&nbsp;</td>
         <td class="STYLE2">&nbsp;</td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td class="STYLE2">添加系统用户</td>
       </tr>
       <tr>
         <td heigth="6"></td>
         <td></td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       </tr>
       <tr>
         <td><div align="right">用 户 名:</div></td>
         <td><label>
           <input name="name" type="text" id="name" size="20" maxlength="20"/>
         *</label></td>
       </tr>
       <tr>
         <td><div align="right">密  码:</div></td>
         <td><label>
           <input name="password" type="password" id="password" size="20" maxlength="20" />
         *</label></td>
       </tr>
       <tr>
         <td><div align="right">重复密码:</div></td>
         <td><label>
           <input name="repassword" type="password" id="repassword" size="20" maxlength="20" />
         *</label></td>
       </tr>
       <tr>
         <td><div align="right">用户角色:</div></td>
         <td>
		 <span id="user">
		 <label>
           <input name="userlevel" type="radio" value="user" checked="checked" />
           操作员
		   </label>
		   </span>
		   <label>
           <input type="radio" name="userlevel" value="admin" />
         管理员</label></td>
       </tr>
       <tr>
         <td><div align="right">部 门:</div></td>
         <td><label>
           <select name="deptno" id="deptno" onChange="func(this)">
		   <option value=""   selected="selected" >请选择		   </option>
		   <? $selectdept="select * from dept order by deptno";
		       $deptno=odbc_exec($conn,$selectdept);
			   while(odbc_fetch_row($deptno))
			   { ?>
             <option value="<? echo odbc_result($deptno,'deptno');?>">
			 <? echo odbc_result($deptno,'deptname');?>			 </option>
			 <? } ?>
         </select>
         *</label></td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       </tr>
       <tr>
         <td><label>
         </label></td>
         <td><label>
          &nbsp;<input name="adduser" type="submit" id="adduser" value="提交" />   
         &nbsp;  
         <input type="reset" name="Submit" value="重置" />
         
         </label></td>
       </tr>
	    <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
       </tr>
	   	   <tr>
	     <td>&nbsp;</td>
	     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="sysuser.php">返回</a></td>
       </tr>
     </table>
</form>
</td>
</tr>
</table>
<? }?>
<p \>
<p \>
 <script src="../copyright.inc">
</script>
</body>
</html>
<? odbc_close($conn);?>

⌨️ 快捷键说明

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