<?php
	include("../include/global.php");
	include("ZC_Check_admin.php");
	global $row;
	if(isset($_POST['submit'])){
		$name=trim($_POST['name']);
		$sql="select * from `".PRE."admin` where name=$name";
		if($db->query($sql)){
			echo "<SCRIPT LANGUAGE='JavaScript'>alert('用户名已存在！');history.go(-1);</SCRIPT>";
			exit;
		}
		$password=md5(trim($_POST['newpass']).ZZCMS);
		$sql1="insert into `".PRE."admin` (`uid`,`grade`,`name`,`password`) values(0,0,'".$name."','".$password."')";
		$db->query($sql1) or die("添加管理员失败".mysql_error());
		echo "<script type='text/javascript'> if(confirm('是否要继续添加?')){ window.location.href='ZC_Article_Manager.php?action=add&tid=0';}else{ window.location.href='ZC_Article_List.php';	}</script>";
		
	}
	
?>
<!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 href="css/Admin.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/public.js"></script>
        	<script language="JavaScript">
			<!--
			function chk(theForm){
					if (theForm.newpass.value == ""){
							alert("新密码不能为空");
							theForm.newpass.focus();
							return (false);
					}
					if (theForm.newpass1.value == ""){
							alert("新密码不能为空");
							theForm.newpass1.focus();
							return (false);
					}
					if (theForm.newpass.value != theForm.newpass1.value){
							alert("两次密码不一致！");
							theForm.newpass1.focus();
							return (false);
					}
			}
			//-->
			</script>
	</head>

<body>
   <form action="" method="post" name="zzcms" id="zzcms" onSubmit="return chk(this)">
        <table align=center border=0 cellspacing=1 cellpadding=5 width="95%">
          <tr>
            <th colspan="2" align="center"><span>修改管理员密码</span></th>
          </tr>
          <tr>
            <td class="td">用户名：</td>
            <td>
            <input name="name" type="text" id="name" style="width:230px;" />请输入要添加的管理员名字
            </td>
          </tr>
          <tr>
            <td class="td">新密码：</td>
            <td><input name="newpass" type="password" id="newpass" style="width:230px;" maxlength="16" />
              请输入新密码</td>
          </tr>
           <tr>
            <td class="td">确认密码：</td>
            <td><input name="newpass1" type="password" id="newpass1" style="width:230px;" maxlength="16" />
              请再次输入新密码</td>
          </tr>
          <tr>
            <td class="td" width="11%">&nbsp;</td>
            <td width="89%">
              <input name="submit" type="submit" class="button" value="修 改" />
            <input name="Reset" type="reset" class="button" id="Reset" value="重 置" /></td>
          </tr>
        
        </table>
   </form>
</body>
</html>
