<?php 
//****************************************请求权限****************************************
require("locked.php");                                                                 //*
setlocked(-1);                                                                         //*
//****************************************************************************************
?>
<html>
<head>
<meta charset="utf-8">
<title>修改用户—恩格会计管理系统</title>
<script language="javascript" type="text/javascript" src="myJs.js"></script>
<link rel="stylesheet" href="myCss.css" type="text/css" />
<script language="javascript" type="text/javascript">
<!--
function checkForm(){
	if (form1.id.value==""){
	    alert("ID不能为空！");
		form1.id.focus();
		return false;
	}
	
	if (isNaN(form1.id.value)){
	    alert("ID必须为数字！");
		form1.id.focus();
		return false;
	}
	
	if (form1.id.value=='1001'){
	    alert("ID值不合法！");
		form1.id.focus();
		return false;
	}
	
	if((form1.id.value).substring(0,1)==0){
		alert("ID起始不能为零！");
		form1.id.focus();
		return false;
	}
	
	if (form1.name.value==""){
	    alert("名称不能为空！");
		form1.name.focus();
		return false;
	}
	
	if (form1.name.value=='admin' || form1.name.value=='是' || form1.name.value=='否'){
		alert("名称值不合法！");
		form1.name.focus();
		return false;
	}
	
	//会计科目，基础资料名称文字禁止出现的数据 arrban 列举的字符；
	for(var i=0;i<arrban.length;i++){
		if((form1.name.value).indexOf(arrban[i])!=-1){
			alert("名称字符不能出现："+arrban[i]);
			form1.name.focus();
			return false;
		}
	}
	
	if (form1.telephone.value==""){
	    alert("电话不能为空！");
		form1.telephone.focus();
		return false;
	}
	
	form1.submit();
}
//-->
</script>
</head>

<body>
<?php
include("cnn.php");
$keyword=$mysqli->real_escape_string($_GET[keyword]);
$strsql='select * from user where id="'.$keyword.'"';
$sql=$mysqli->query($strsql);
$info=$sql->fetch_array(MYSQLI_BOTH);
if($info){ //如果存在数据；
	if($info[id]=='1001'){
	echo '<form action="userEditSubmit.php" method="post" name="form1">
		  <table>
		  <tr>
		  <td>ID</td><td><input name="id" type="text" value='.$info[id].' readonly /></td>
		  </tr>
		  <tr>
		  <td>名称</td><td><input name="name" type="text" value='.$info[name].' readonly /></td>
		  </tr>
		  <tr>
		  <td>电话</td><td><input name="telephone" type="text" value='.$info[telephone].' /></td>
		  </tr>
		  <tr>
		  <td>重置密码</td>
		  <td>
		  <select name="resetpwd">
		  <option value="0" selected="selected">否</option>
		  <option value="1">是</option>
		  </select>
		  </td>
		  </tr>
		  <tr>
		  <td colspan="2" align="center"><input name="insert" type="button" onClick="checkForm()" value="保存" /></td>
		  </tr>
		  </table>
		  </form>';	
	}else{
	echo '<form action="userEditSubmit.php" method="post" name="form1">
		  <table>
		  <tr>
		  <td>ID</td><td><input name="id" type="text" value='.$info[id].' readonly /></td>
		  </tr>
		  <tr>
		  <td>名称</td><td><input name="name" type="text" value='.$info[name].' /></td>
		  </tr>
		  <tr>
		  <td>电话</td><td><input name="telephone" type="text" value='.$info[telephone].' /></td>
		  </tr>
		  <tr>
		  <td>重置密码</td>
		  <td>
		  <select name="resetpwd">
		  <option value="0" selected="selected">否</option>
		  <option value="1">是</option>
		  </select>
		  </td>
		  </tr>
		  <tr>
		  <td colspan="2" align="center"><input name="insert" type="button" onClick="checkForm()" value="保存" /></td>
		  </tr>
		  </table>
		  </form>';
	}
}
$sql->free();
$mysqli->close();
?>
</body>
</html>