<!--#include file="Conn.asp"--><%Checklogin()%>
<!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="css/common.css" type="text/css" />
<script language="javascript" src="system/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="system/xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>

</head>
<body class="clear">
<!--#include file="panel.asp"-->
<div id="man_zone">
<%

id = Request.QueryString("id")
Page = Request.QueryString("Page")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
Ord=Server.UrlEnCode(Request.QueryString("Ord"))
hrefstr = "?keys="&Keys&"&Ord="&Ord&"&Page="&Page
employee_id=Session("employee_id")

act=Request.QueryString("act")


If act="save" Then
	em_tel=TextEncode(Request.Form("em_tel"))
	em_email=TextEncode(Request.Form("em_email"))	
	em_password=MD5(Request.Form("em_password"))
	pwd=MD5(Request.Form("pwd"))
	pwdre=MD5(Request.Form("pwdre"))
	editpwd=false
	
	If Not IsNumeric(employee_id) Then employee_id=0

	

	If pwd<>"8f00b204e9800998" and pwdre<>"8f00b204e9800998" Then
	    editpwd=true
		If pwd<>pwdre Then
			conn.close
			set conn=Nothing
			Response.write "<script>alert('两次密码输入不一致!');history.back();</script>"
			Response.end
		End if	
	End if
	
		
	Set Rs = Server.CreateObject("ADODB.RecordSet")
		Rs.Open "select * from employee where id="&employee_id,conn,1,3
			If Not Rs.bof and Not Rs.eof Then
					Rs("em_email")=em_email
					Rs("em_tel")=em_tel	
					changeSuccess=1
					If editpwd Then
						 If em_password=Rs("em_password") Then
							Rs("em_password")=pwd	
							changeSuccess=2
						 Else
							changeSuccess=3
						 End IF 
					End IF 
					
			End IF	
		Rs.update
		Rs.Close
	Set Rs=Nothing
	conn.close
	set conn=Nothing			
		
			
	If Cint(changeSuccess)=1 Then
		Response.write "<script>alert('资料修改成功!');history.back();</script>"
	ElseIf Cint(changeSuccess)=2 Then
		Response.write "<script>alert('密码修改成功!请退出重新登录');location.href='index.php?act=logout';</script>"
	Else
		Response.write "<script>alert('原始密码错误!');history.back();</script>"
	End If	
	
	Response.End	
			
End If'End act

Set Rs = Server.CreateObject("ADODB.RecordSet")
	Rs.Open "select em_email,em_tel from employee where id="&Session("employee_id"),conn,1,1
		em_tel=Rs("em_tel")
		em_email=Rs("em_email")		
	Rs.Close
Set Rs = Nothing
%>
	<form name="form1" method="post" action="pwdEdit.asp<%=hrefstr%>&act=save" onSubmit="return checkpwd();">
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<tbody>
			<tr>
				<th width="8%">电话:</th>
				<td><input type="text" id="em_tel" name="em_tel" value="<%=em_tel%>" class="txt1" /></td>
			</tr>		
			<tr>
				<th width="8%">邮箱:</th>
				<td><input type="text" id="em_email" name="em_email" value="<%=em_email%>" class="txt1" /></td>
			</tr>				
			<tr>
				<th width="8%">原始密码:</th>
				<td><input type="password" id="em_password" name="em_password" value="" class="txt1"  placeholder="不修改密码请留空"/></td>
			</tr>
			<tr>
				<th width="8%">新密码:</th>
				<td><input type="password" id="pwd" name="pwd" value="" class="txt1" placeholder="不修改密码请留空" /></td>
			</tr>
			<tr>
				<th width="8%">请再次输入</th>
				<td><input type="password" id="pwdre" name="pwdre" value="" class="txt1" placeholder="不修改密码请留空" /></td>
			</tr>
			<tr>
				<th></th>
				<td><input type="submit" name="save" id="save" value="确定" class="btn1" /></td>
			</tr>
			

		</tbody>
	</table>
	</form>
</div>
</body>
</html>
<%Conn.Close:Set Conn=Nothing%>