<!--#include file="conn/conn_index.asp"-->
<!--#include file="inc/setup.asp"-->
<!--#include file="inc/money.asp"-->
<!--#include file="inc/char.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/sql.asp"-->
<%
	end if
	action=ReplaceBadChar(Trim(Request("action")))
	
	if action="e2" then
	
		If Session("getcode")<>int(ReplaceBadChar(Trim(Request.Form("CheckCode")))) Then
			response.write"<SCRIPT language=JavaScript>alert('验证码输入错误');"
			response.write"javascript:history.go(-1)</SCRIPT>"
			response.end
		else
			UserName=ReplaceBadChar(Trim(Request.Form("UserName")))
			question=ReplaceBadChar(Trim(Request.Form("question")))
			if question="cus" then
				custom_question=ReplaceBadChar(Trim(Request.Form("custom_question")))
				if custom_question="" then
					response.write"<SCRIPT language=JavaScript>alert('自定义问题不能为空，请重来');"                   
					response.write"javascript:history.go(-1)</SCRIPT>"                   
					response.end
				else
					question=custom_question
				end if
			end if
			answer=ReplaceBadChar(Trim(Request.Form("answer")))
			usertype=ReplaceBadChar(Trim(Request.Form("usertype")))
			
			if usertype="person" then go="p"
			if usertype="company" then go="c"
			if usertype="school" then go="s"
			if usertype="train" then go="t"
			
			if usertype="person" then type1="person"
			if usertype="company" then type1="company"
			if usertype="school" then type1="school"
			if usertype="train" then type1="train"
			
			if usertype="person" then type2="uname"
			if usertype="company" then type2="uname"
			if usertype="school" then type2="sname"
			if usertype="train" then type2="tname"
			
			if usertype<>"person" and usertype<>"company" and usertype<>"school" and usertype<>"train" then
				response.write"<SCRIPT language=JavaScript>alert('非法操作');"            
				response.write"javascript:history.go(-1)</SCRIPT>"
				response.End
			end if
			
			Set rs = Server.CreateObject("ADODB.Recordset")
			sql="select * from "&type1&" where "&type2&"='"&UserName&"'"
			rs.open sql,conn,2,3
			if rs.eof then
				response.write"<SCRIPT language=JavaScript>alert('对不起,该用户不存在，请查询');"            
				response.write"javascript:history.go(-1)</SCRIPT>"
			else
				if rs("question")<>question or rs("answer")<>answer then
					response.write"<SCRIPT language=JavaScript>alert('对不起,密码找回问题或者密码错误,请查询');"            
					response.write"javascript:history.go(-1)</SCRIPT>"
					response.end
				end if
				
				function gen_key(digits)
				dim rndnum,num
				Randomize
				Do while Len(rndnum)<digits
				num = Cstr(Chr((57-48)*rnd+48))
				rndnum = rndnum & num
				Loop
				gen_key = rndnum
				End function
				email=rs("email")
				pwd=gen_key(10)
				rs("pwd")=mistake(pwd)
				rs.update
				rs.close
				set rs=nothing
		'以下为发送邮件代码
			
			
					Set rs = Server.CreateObject("ADODB.Recordset")
					sql="select * from sendmail"
					rs.open sql,conn,1,1
					if rs("open1")=0 then
						mailaddress=rs("mailaddress")
						mailusername=rs("mailusername")
						mailuserpass=rs("mailuserpass")
						mailname=rs("mailname")
						mailsend=rs("mailsend")
					
					
						'发送邮件
						'if Forum_Setting(47)=1 then
						On Error Resume Next
						'发送注册邮件
						topic="您在"&homename&"的修改密码的资料"
						
						mailbody="<html>"
						mailbody=mailbody & "<title>修改密码的资料</title>"
						mailbody=mailbody & "<body>"
						mailbody=mailbody & "<TABLE border=0 width='95%' align=center><TBODY><TR>"
						mailbody=mailbody & "<TD valign=middle align=top>"
						mailbody=mailbody & trim(request("UserName"))&"，您好：<br><br>"
						mailbody=mailbody & "您在"&homename&"注册的帐号信息发生改变，下面是你最新的帐号信息！<br>"
						mailbody=mailbody & "下面是您在"&homename&"的注册信息：<br><br>"
						mailbody=mailbody & "注册名："&trim(request("UserName"))&"<br>"
						mailbody=mailbody & "密  码："&pwd&"<br>"
						mailbody=mailbody & "网站地址："&homeurl&"<br><br>"
						mailbody=mailbody & ""&rs("mailtext")&"<br><br><br>"
						mailbody=mailbody & "<center><font color=red>再次感谢您注册"&homename&"</font>"
						mailbody=mailbody & "</TD></TR></TBODY></TABLE><br><hr width=95% size=1>"
						mailbody=mailbody & "</body>"
						mailbody=mailbody & "</html>"
						rs.close
						set rs=nothing
						
						Set JMail=Server.CreateObject("JMail.Message")
						JMail.Charset="gb2312"
						JMail.ContentType = "text/html"
						jmail.from = mailsend
						jmail.silent = true
						jmail.Logging = true
						jmail.FromName = mailname
						jmail.mailserverusername = mailusername
						jmail.mailserverpassword = mailuserpass
						jmail.AddRecipient email
						jmail.body=mailbody
						JMail.Subject=topic
						if not jmail.Send ( mailaddress ) then
							SendMail=""
						else
							SendMail="OK"
						end if
						if SendMail="OK" then
							sendmsg="· 恭喜你,密码修改成功,新密码已经发送到您注册的邮箱中，请注意查收!"
						else
							sendmsg="· 系统出错，新密码资料未能发送到您的邮箱,请与管理员联系!"
						end if
					else
						rs.close
						set rs=nothing
					end if
		
		'邮件发送  代码结束
		
			response.write"<SCRIPT language=JavaScript>alert('"&sendmsg&"');"            
			response.write"this.location.href='login.asp';</SCRIPT>"
			end if
		end if
	end if
%>
<!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>
<link rel="Shortcut Icon" href="Images/favicon.ico">
<link rel="Bookmark" href="Images/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<TITLE><%= homename %>--企业会员注册</TITLE>
<meta name="Keywords" content="<%= webmeta %>">
<script language=JavaScript src="js/preg.js"></script>
<meta name="Description" content="<%= webmeta1 %>">
<style type="text/css">
<!--
.STYLE6 {	color: #0099CC;
	font-size: 12pt;
	font-weight: bold;
	}
.STYLE2 {	color: #ffffff;
	font-size: 14pt;
	font-weight: bold;
}
.style193 {color: #FF6600}
.style193 {color: #FF6600}
body,td,th {
	font-size: 12px;
}
body {
	background-image: url(images/preg/indextopbackground.gif);
	background-repeat:repeat-x;
	margin-left: 0px;
	margin-top: 204px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="css/preg.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE7 {color: #FF0000}
-->
</style>
</HEAD>
<BODY>
<%
	If action="e1" Then
	
		If Session("getcode")<>int(ReplaceBadChar(Trim(Request.Form("CheckCode")))) Then
			response.write"<SCRIPT language=JavaScript>alert('验证码输入错误');"
			response.write"javascript:history.go(-1)</SCRIPT>"
			response.end
		else
			UserName=ReplaceBadChar(Trim(Request.Form("UserName")))
			usertype=ReplaceBadChar(Trim(Request.Form("usertype")))
			
			if usertype="person" then go="p"
			if usertype="company" then go="c"
			if usertype="school" then go="s"
			if usertype="train" then go="t"
			
			if usertype="person" then type1="person"
			if usertype="company" then type1="company"
			if usertype="school" then type1="school"
			if usertype="train" then type1="train"
			
			if usertype="person" then type2="uname"
			if usertype="company" then type2="uname"
			if usertype="school" then type2="sname"
			if usertype="train" then type2="tname"
			
			if usertype<>"person" and usertype<>"company" and usertype<>"school" and usertype<>"train" then
				response.write"<SCRIPT language=JavaScript>alert('非法操作');"            
				response.write"javascript:history.go(-1)</SCRIPT>"
				response.End
			end if
			
			Set rs = Server.CreateObject("ADODB.Recordset")
			sql="select * from "&type1&" where "&type2&"='"&UserName&"'"
			rs.open sql,conn,1,1
			if rs.eof then
				response.write"<SCRIPT language=JavaScript>alert('对不起,该用户不存在，请查询');"            
				response.write"javascript:history.go(-1)</SCRIPT>"
			else
				question=rs("question")
			end if
			rs.close
			set rs=nothing
		end if
	end if
%>
<table width="977"  border="0" align="center" cellpadding="4" cellspacing="0">
  <tr>
    <td width="220" height="30" bgcolor="#77CD38"><img src="images/forgetpw/password.jpg" width="33" height="30" /></td>
    <td width="290" bgcolor="#77CD38"><strong class="white">找回登录密码</strong></td>
  </tr>
</table>
<table width="977" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#77CD38">
  <tr>
    <td bordercolor="#FFFFFF" bgcolor="#FFFFFF"><span class="greenfont"><img src="images/forgetpw/p5.gif" width="32" height="20" /> 如果您忘记了<%= homename %><span lang="en-us" xml:lang="en-us">(<%= replace(homeurl, "http://www.", "") %>)</span>的帐号密码，请首先使用下面的找回密码功能找回密码，如果没有<span class="greenfont style1">请发mail给</span></span><span class="S4"><%= delemail(ymail) %></span><span class="greenfont"><span class="greenfont style1">，说明你的用户名和姓名，我们会尽快给你回复邮件告诉你新密码。</span> </span>
      <br />
      <br />
      <span class="greenfont"><font color="#ff6600"><strong>注意：</strong> </font>使用下面找回密码功能找回密码，你必须在注册时填写了正确的<span lang="en-us" xml:lang="en-us">email</span>地址,</span>
      <table cellspacing="0" cellpadding="2" width="100%" align="center" border="0">
      <form action="?" method="post" name="fm" id="fm" onsubmit="return checkfm();">
      <input name="action" type="hidden" value="<% If action="" Then Response.Write("e1") else Response.Write("e2")%>" />
       			<tr>
                            <td width="315" height="35" align="right" valign="middle">用户名：</td>
<td height="35" colspan="2" align="left" valign="middle">
							<input name="UserName" class="form1txt" id="UserName"  style="width:210px;" maxlength="16"  value="<%= UserName %>" <% If UserName<>"" Then Response.Write("readonly")%>/>
                                <span class="STYLE7">您在注册时使用的用户名</span></td>
                          </tr>
						  <tr>
                            <td height="35" align="right" valign="middle">类　别：</td>
                          <td height="35" colspan="2" align="left" valign="middle">
                                <input name="usertype" type="radio" <% If Trim(Request.Form("usertype"))="person" or Trim(Request.Form("usertype"))="" Then Response.Write("checked")%> value="person" <% If Trim(Request.Form("usertype"))<>"person" and Trim(Request.Form("usertype"))<>"" Then Response.Write("disabled")%>>
                                个人
                                <input type="radio" name="usertype" <% If Trim(Request.Form("usertype"))="company" Then Response.Write("checked")%> value="company" <% If Trim(Request.Form("usertype"))<>"company" and Trim(Request.Form("usertype"))<>"" Then Response.Write("disabled")%>>
                                企业                                
                                <input name="usertype" type="radio" <% If Trim(Request.Form("usertype"))="school" Then Response.Write("checked")%> value="school" <% If Trim(Request.Form("usertype"))<>"school" and Trim(Request.Form("usertype"))<>"" Then Response.Write("disabled")%>>
                                院校
                                <input type="radio" name="usertype" <% If Trim(Request.Form("usertype"))="train" Then Response.Write("checked")%> value="train" <% If Trim(Request.Form("usertype"))<>"train" and Trim(Request.Form("usertype"))<>"" Then Response.Write("disabled")%>>
                                培训</td>
                          </tr>
<%
	If action="e1" Then
		if question<>"您的家乡是?" and question<>"您初中的语文老师是?" and question<>"您最尊重的人是?" and question<>"您最爱吃的菜是?" and question<>"您最爱读的书是?" and question<>"您最喜欢的一首歌是?" and question<>"您最喜欢的运动是?" and question<>"您最喜欢的电影是?" and question<>"您最喜欢的节日是?" and question<>"您最想去的地方是?" and question<>"您最想做的事情是?" and question<>"您最难忘的事情是?" then
			question1="cus"
		Else
			question1=question
		end if
		
%>
                          <tr>
                            <td height="35" align="right" valign="middle">问　题：</td>
                          <td height="35" colspan="2" align="left" valign="middle"><select style="width:210px;" name="question" id="question" onchange="checkQuestion()">
						<option value="" <% If question1="" Then Response.Write("selected")%>>[请选择您的密码提示问题] </option>
						<option value="cus" <% If question1="cus" Then Response.Write("selected")%>>***自定义密码提示问题***</option>
						<option value="您的家乡是?" <% If question1="您的家乡是?" Then Response.Write("selected")%>>您的家乡是?</option>
						<option value="您初中的语文老师是?" <% If question1="您初中的语文老师是?" Then Response.Write("selected")%>>您初中的语文老师是?</option>
						<option value="您最尊重的人是?" <% If question1="您最尊重的人是?" Then Response.Write("selected")%>>您最尊重的人是?</option>
						<option value="您最爱吃的菜是?" <% If question1="您最爱吃的菜是?" Then Response.Write("selected")%>>您最爱吃的菜是?</option>
						<option value="您最爱读的书是?" <% If question1="您最爱读的书是?" Then Response.Write("selected")%>>您最爱读的书是?</option>
						<option value="您最喜欢的一首歌是?" <% If question1="您最喜欢的一首歌是?" Then Response.Write("selected")%>>您最喜欢的一首歌是?</option>
						<option value="您最喜欢的运动是?" <% If question1="您最喜欢的运动是?" Then Response.Write("selected")%>>您最喜欢的运动是?</option>
						<option value="您最喜欢的电影是?" <% If question1="您最喜欢的电影是?" Then Response.Write("selected")%>>您最喜欢的电影是?</option>
						<option value="您最喜欢的节日是?" <% If question1="您最喜欢的节日是?" Then Response.Write("selected")%>>您最喜欢的节日是?</option>
						<option value="您最想去的地方是?" <% If question1="您最想去的地方是?" Then Response.Write("selected")%>>您最想去的地方是?</option>
						<option value="您最想做的事情是?" <% If question1="您最想做的事情是?" Then Response.Write("selected")%>>您最想做的事情是?</option>
						<option value="您最难忘的事情是?" <% If question1="您最难忘的事情是?" Then Response.Write("selected")%>>您最难忘的事情是?</option>
					</select>
                                <span class="STYLE7">您在申请时用户时填写的用于取回密码的问题</span></td>
</tr>
						<tr  id="cus_question" style="display:<% If question1<>"cus" Then Response.Write("none")%>">
                        <td align="right" bgcolor="#FFFFFF" class="tb_c_ttl vt"><span style="FONT-SIZE: 12px; FONT-FAMILY: 宋体">自定义问题：</span></td>
                        <td align="left" bgcolor="#FFFFFF" class="tb_c_con vt" colspan="2"><input type="text" style="width:205px;" class="minput" name="custom_question" id="custom_question"  value="<%= question %>"/></td>
          </tr>
                      <tr>
                        <td align="right" bgcolor="#FFFFFF" class="tb_c_ttl vt"><span style="FONT-SIZE: 12px; FONT-FAMILY: 宋体">问题的答案：</span></td>
                      <td align="left" bgcolor="#FFFFFF" class="tb_c_con vt" colspan="2"><input name="answer" id="answer" size="32" class="minput" style="width:205px;" /></td>
                      </tr>
<% End If %>
						  <tr>
                            <td height="35" align="right" valign="middle">验证码：</td>
                            <td width="143" height="35" align="left" valign="middle"><input name="CheckCode" class="form1txt" id="CheckCode"  size="16" maxlength="4" />                            </td>
                            <td width="495" align="left" valign="middle"><img src="GetCode.asp" vspace="2" align="absmiddle"> </td>
          </tr>
                <tr>
          <td colspan="3" align="center">
            <input class="formbutt" onclick="javascript:checkfm()" type=image src="images/forgetpw/next.gif" width="167" height="35" border="0">
            <input class="formbutt" onclick="javascript:window.close()" type=image src="images/forgetpw/quit.gif" width="167" height="35" border="0"></td>
        </tr>
      </form>
    </table></td>
  </tr>
</table>
</BODY>
</html>
<%
	call closeconn()
%>