<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/char.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	end if
	useflag=3
%>
<!--#include file="flag.asp"-->
<%
	action=Trim(Request.QueryString("action"))
	if action="add" then
		tname=ReplaceBadChar(Trim(Request.Form("uname")))
		pwd_old=Trim(Request.Form("pwd"))
		pwd=mistake(pwd_old)
		email=ReplaceBadChar(Trim(Request.Form("email")))
		question=ReplaceBadChar(Trim(Request.Form("question")))
		answer=ReplaceBadChar(Trim(Request.Form("answer")))
		
		train_name=ReplaceBadChar(Trim(Request.Form("school_name")))
		train_type=ReplaceBadChar(Trim(Request.Form("school_type")))
		province=ReplaceBadChar(int(Trim(Request.Form("hukouprovince"))))
		city=ReplaceBadChar(int(Trim(Request.Form("hukoucapital"))))
		address=ReplaceBadChar(Trim(Request.Form("address")))
		code=ReplaceBadChar(Trim(Request.Form("postcode")))
		weburl=ReplaceBadChar(Trim(Request.Form("site")))
		introduction=Trim(Request.Form("introduce"))
		subject=Trim(Request.Form("course_intro"))
		tea_intro=Trim(Request.Form("teacher_intro"))
		lx_person=ReplaceBadChar(Trim(Request.Form("linkman")))
		phone=ReplaceBadChar(Trim(Request.Form("phone")))
		fax=ReplaceBadChar(Trim(Request.Form("fax")))
		hukoucity=ReplaceBadChar(Trim(Request.Form("hukoucity")))
		if fax="" then fax="未填写"
		if code="" then code="未填写"
		if weburl="" then weburl="未填写"
				
		Set rs = Server.CreateObject("ADODB.Recordset")
		sql="select * from train where tname='"&uname&"'"
		rs.open sql,conn,2,3
		if rs.eof then
		
			rs.addnew
			rs("tname")=tname
			rs("pwd")=pwd
			rs("email")=email
			rs("question")=question
			rs("answer")=answer
			rs("train_name")=train_name
			rs("train_type")=train_type
			rs("province")=province
			rs("city")=city
			rs("address")=address
			rs("code")=code
			rs("weburl")=weburl
			rs("introduction")=introduction
			rs("subject")=subject
			rs("tea_intro")=tea_intro
			rs("lx_person")=lx_person
			rs("phone")=phone
			rs("fax")=fax
			rs("area")=hukoucity
			rs("logo")="nophoto.gif"
			rs("setup")=now()
			rs("lock")=0
			rs("hideuser")=0
			rs("dlnum")=0
			rs("begintime")=now()
			rs("endtime")=now()
			rs("subject_num")=train_subject_num
			rs("zhuangtai")=train_zhuangtai
			rs.update
			set rs=nothing
			
			kk=conn.Execute("select id from train where tname='"&tname&"'")(0)
			
			Set rs = Server.CreateObject("ADODB.Recordset")
			sql="select * from tmailbox"
			rs.open sql,conn,2,3
			rs.addnew
			rs("reid")=kk
			rs("senduid")="0"
			rs("title")=tsmailtitle
			rs("sendname")="系统管理员"
			rs("sdate")=date()
			rs("mailtext")=tsmailtext
			rs.update
			rs.close
			set rs=nothing

		'以下为电子邮件发送代码
			Set rs_mail = Server.CreateObject("ADODB.Recordset")
			sql_mail="select * from sendmail"
			rs_mail.open sql_mail,conn,1,1
			if rs_mail("open1")=0 and train_reg=0 then
				mailaddress=rs_mail("mailaddress")
				mailusername=rs_mail("mailusername")
				mailuserpass=rs_mail("mailuserpass")
				mailname=rs_mail("mailname")
				mailsend=rs_mail("mailsend")
				rs_mail.close
				set rs_mail=nothing
				
				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("tname"))&"，您好：<br><br>"
				mailbody=mailbody & "欢迎您注册"&homename&"，我们将提供给您最好的服务！<br>"
				mailbody=mailbody & "下面是您在"&homename&"的注册信息：<br><br>"
				mailbody=mailbody & "注册名："&trim(request("tname"))&"<br>"
				mailbody=mailbody & "密  码："&pwd_old&"<br>"
				mailbody=mailbody & "密码问题："&question&"<br>"
				mailbody=mailbody & "密码答案："&answer&"<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>"
				
				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 Trim(Request.Form("Email"))
				jmail.body=mailbody
				JMail.Subject=topic
				if not jmail.Send ( mailaddress ) then
					SendMail=""
				else
					SendMail="OK"
				end if
			end if
		'邮件发送代码完毕
		
			Response.Cookies("admin_train_id")=kk
					
			Response.Cookies("admin_train_id").expires=(now()+1/24)

			set fs=createobject("scripting.filesystemobject")
			MyFolder=server.mappath("../html/train/"&kk&"")
			If NOT fs.folderexists(MyFolder) then
				fs.createfolder(MyFolder)
			End If

			response.write"<SCRIPT language=JavaScript>alert('院校用户注册成功，现在为您返回');"
			response.write"this.location.href='train_main_html.asp';</script>"
			response.end
			
		else
		
			response.write"<SCRIPT language=JavaScript>alert('该用户名已存在，请重来');"
			response.write"javascript:history.go(-1)</SCRIPT>"
			response.end
			
		end if
		rs.close
		set rs=nothing
		conn.close
		set conn=nothing
	end if
%>
<html>
<head>
<title>添加培训机构资料</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href=Include/style.css rel=stylesheet type="text/css">
<script language="JavaScript" type="text/javascript" src="../inc/keyfilter.js"></script>
<script language="JavaScript">
<!--
//功能：去掉字符串前后空格
//返回值：去掉空格后的字符串
function fnRemoveBrank(strSource)
{
 return strSource.replace(/^\s*/,'').replace(/\s*$/,'');
}
function GethukouCapital(capitalid)
{
document.frames["hukoucapitalframe"].location.replace("../inc/gethukoucapital.asp?capitalid="+capitalid);
}
function GethukouCity(cityid)
{
document.frames["hukoucityframe"].location.replace("../inc/gethukoucity.asp?cityid="+cityid);
}
function String.prototype.lenB()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
function checkUserExist(theForm){
	if (fnRemoveBrank(userinfo.uname.value)== "") {
		alert ('请输入会员帐号 ！');
		userinfo.uname.focus();
		return false;
	}else{
		window.open("checkUser.asp?usertype=train&login="+userinfo.uname.value,"","width=340,height=200,scrollbars=no");
	}
	return false;
}
function checkuserinfo()
{
   if(document.userinfo.uname.value == "") {
	document.userinfo.uname.focus();
    alert("对不起，请填写用户名！");
	return false;
  }
   if(document.userinfo.pwd.value == "") {
	document.userinfo.pwd.focus();
    alert("对不起，请填写密码！");
	return false;
  }
   if(document.userinfo.pwd1.value == "") {
	document.userinfo.pwd1.focus();
    alert("对不起，请填写确认密码！");
	return false;
  }
    if(document.userinfo.pwd.value != document.userinfo.pwd1.value) {
	document.userinfo.pwd.focus();
	document.userinfo.pwd.value = '';
	document.userinfo.pwd1.value = '';
    alert("两次输入的密码不同，请重新输入！");
	return false;
  }
   if(document.userinfo.email.value =="") {
	document.userinfo.email.focus();
    alert("对不起，请填写电子邮件地址！");
	return false;
  }
   if(document.userinfo.question.value =="") {
	document.userinfo.question.focus();
    alert("对不起，请填写密码提问！");
	return false;
  }
   if(document.userinfo.answer.value=="") {
	document.userinfo.answer.focus();
    alert("对不起，请填写密码提问的答案！");
	return false;
  }
  
   if(document.userinfo.school_name.value=="") {
	document.userinfo.school_name.focus();
    alert("对不起，请填写机构名称！");
	return false;
  }
   if(document.userinfo.school_type.value=="") {
	document.userinfo.school_type.focus();
    alert("对不起，请填写机构类别！");
	return false;
  }
   if(document.userinfo.hukouprovince.value=="") {
	document.userinfo.hukouprovince.focus();
    alert("对不起，请填写所在地区！");
	return false;
  }
   if(document.userinfo.address.value=="") {
	document.userinfo.address.focus();
    alert("对不起，请填写机构地址！");
	return false;
  }
   if(document.userinfo.linkman.value=="") {
	document.userinfo.linkman.focus();
    alert("对不起，请填写联系人！");
	return false;
  }
   if(document.userinfo.phone.value=="") {
	document.userinfo.phone.focus();
    alert("对不起，请填写联系电话！");
	return false;
  }
}
//-->
</script>
<iframe height=0 width=0 src="" id="hukoucapitalframe"></iframe>
<iframe height=0 width=0 src="" id="hukoucityframe"></iframe>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
   <tr> 
  <th height=25 colspan="6" class="tableHeaderText">添加培训机构资料</th> 
  </tr>
  <form action="?action=add" method="post" name="userinfo" onSubmit="return checkuserinfo()">
    <TBODY>
      <TR > 
        <TD height=25 colSpan=6 align=left class="amrow"><FONT color=#333333>（注：带</FONT><FONT color=#ff6600>＊</FONT><FONT color=#b00000><FONT color=#333333>号为必填项）</FONT></FONT>        </TD>
      </TR>
      <tr > 
        <td height=25 colspan="6" class="huiby"><font color="#FF0000"><strong>基本资料</strong></font></td>
      </tr>
      <tr > 
        <td height="25" colspan="6" class="huiby">
            <table border="0" width="100%" align="center">
              <tr> 
                <td width="16%" align="right">会员帐号：</td>
                <td width="84%"><input name="uname" id="uname" maxlength=20 onKeyPress="keyFilter('1234567890abcdefghijklmnopqrstuvwxyz_')" onpaste="return false" onMouseOver="focus();select();" style="IME-MODE: disabled;width:130px">
                  <FONT color=#ff6600>＊</FONT> （为字母或数字，4-20个字符） 
                <input name="checkUsername" type="button" value="查看会员帐号是否占用" onClick="checkUserExist();" ></td>
              </tr>
              <tr> 
                <td align="right">会员密码：</td>
                <td><input name="pwd" type="password" id="pwd" value="" maxlength="20" style="width:130px">
                  <FONT color=#ff6600>＊</FONT> （为字母或数字，4-20个字符）</td>
              </tr>
			  <tr> 
                <td align="right">确认密码：</td>
                <td><input name="pwd1" type="password" id="pwd1" value="" style="width:130px" maxlength="20">
                <FONT color=#ff6600>＊</FONT> </td>
              </tr>
			  <tr> 
                <td align="right">邮&nbsp;&nbsp;&nbsp;箱：</td>
                <td><input name="email" type="text" id="email" value="" style="width:130px" maxlength="20">                 
                   <FONT color=#ff6600>＊</FONT> （邮箱需要验证，请正确填写）</td>
              </tr>
              <tr> 
                <td align="right">密码提示问题：</td>
                <td><input name="question" type="text" id="question" value="" style="width:130px" maxlength="20">
                  <FONT color=#ff6600>＊</FONT> （忘记密码的提示问题答案，用于取回本站的密码）</td>
              </tr>
              <tr> 
                <td align="right">密码提示问题的答案：</td>
                <td><input name="answer" type="text" id="answer" value="" style="width:130px" maxlength="20">
                  <FONT color=#ff6600>＊</FONT> </td>
              </tr>
            </table>			</td>
      </tr>
      <TR> 
        <TD height=25 align=right class="amrow" width="12%"><FONT color=#ff6600>＊</FONT>机构名称：</TD>
        <TD width="19%" align=left class="amrow"><input name="school_name" type="text" class="input" id="school_name" value="" size="20"></TD>
        <TD width="10%" align=right class="amrow"><span class="huiby"><font color="#ff6600">＊</font>机构类别：</span></TD>
        <TD align=left class="amrow" width="16%">
<select name="school_type" id="school_type" check_str="机构类别">
              <option value="">=请选择=</option>
              <option value='电脑培训'>电脑培训</option>
                <option value='职业技能'>职业技能</option>
                  <option value='资格认证'>资格认证</option>
                    <option value='学历招生'>学历招生</option>
                    <option value='企业管理'>企业管理</option>
                    <option value='语言培训'>语言培训</option>
                    <option value='家教中心'>家教中心</option>
                    <option value='少儿培训'>少儿培训</option>
                    <option value='艺术健身'>艺术健身</option>
                    <option value='出国留学'>出国留学</option>
                    <option value='其它培训'>其它培训</option>
          </select>
		</TD>
        <TD width="11%" align=right class="amrow"><span class="huiby"><font color="#ff6600">＊</font>所在地区：</span></TD>
        <TD align=left class="amrow" width="32%">
<select name="hukouprovince" size="1" id="select11" onChange=GethukouCapital(this.options[this.selectedIndex].value) style="width:77px ">
                            <option value="0" selected>省份</option>
<%
	set rs_job=server.createobject("adodb.recordset")
	job_sql="select * from job_provinceandcity where fid=0 order by date desc"
	rs_job.open job_sql,conn,1,1
	do while not rs_job.eof
	response.write"<OPTION value="&rs_job("id")&">"&rs_job("province_city")&"</option>"
	rs_job.movenext
	loop
	rs_job.close
	set rs_job=nothing
%>
		  </select><span id="load300"></span> <span id="chukoucapital">
                          <select name=hukoucapital id="select12" onchange=GethukouCity(this.options[this.selectedIndex].value) style="width:77px ">
                            <option value="0" selected>地级市</option>
                          </select>
                          </span><span id="load400"></span>
<span id="chukoucity">
<select name=hukoucity id="hukoucity">
<option value="" selected>县级地区</option>
</select>
</span>
		</TD>
      </TR>
      <TR align="right" > 
        <TD height=25 class="huiby"><span class="amrow"><font color="#ff6600">＊</font>机构地址：</span></TD>
        <TD align="left" class="huiby"><input name="address" type="text" class="input" id="address" value="" size="20"></TD>
        <TD class="huiby">邮政编码：</TD>
        <TD align="left" valign="middle" class="huiby"><input name="postcode" type="text" class="input" id="postcode" style="ime-mode:disabled" value="" size="8"></TD>
        <TD align=right class="huiby">机构网站<span class="amrow">：</span></TD>
        <TD align="left" class="huiby"><input name="site" type="text" class="input" id="site" value="" size="20"></TD>
      </TR>
      <TR > 
        <TD height=25 align=right class="amrow"><span class="huiby"><font color="#ff6600">＊</font>联 系 人：</span></TD>
        <TD align=left class="amrow" ><input name="linkman" type="text" class="input" id="linkman" value="" size="20" check_str="联系人"></TD>
        <TD align=right class="amrow" ><font color="#ff6600">＊</font>联系电话：</TD>
        <TD align=left class="amrow" ><input name="phone" type="text" class="input" id="phone" style="ime-mode:disabled" value="" size="20"></TD>
        <TD align=right class="amrow" >传　　真：</TD>
        <TD align=left class="amrow" ><input name="fax" type="text" class="input" id="fax" style="ime-mode:disabled" value="" size="20"></TD>
      </TR>
	  <tr align="right"> 
        <td height=25 colspan="6" align="left" class="forumRow"><font color="#FF0000"><strong>其他信息</strong></font></td>
      </tr>
      <TR > 
        <TD height=25 align=right valign="middle" class="huiby"><FONT color=#ff6600>＊</FONT>机构介绍：</TD>
        <TD colspan="5" align=left class="huiby"><textarea name="introduce" rows="8" style="width: 500px;font-size: 12px;display:none;" cols="20"></textarea><iframe ID="Editor" name="Editor" src="../HtmlEditor/index.html?ID=introduce" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:130px;width:100%"></iframe></TD>
      </TR>
      <TR > 
        <TD height=25 align=right valign="middle" class="amrow"><FONT color=#ff6600>＊</FONT>主要课程：</TD>
        <TD colspan="5" align=left class="amrow"><textarea name="course_intro" rows="8" style="width: 500px;font-size: 12px;display:none;" cols="20"></textarea><iframe ID="Editor" name="Editor" src="../HtmlEditor/index.html?ID=course_intro" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:130px;width:100%"></iframe></TD>
      </TR>
      <TR > 
        <TD height=25 align=right valign="middle" class="huiby"><FONT color=#ff6600>＊</FONT>师资介绍：</TD>
        <TD colspan="5" align=left class="huiby"><textarea name="teacher_intro" rows="8" style="width: 500px;font-size: 12px;display:none;" cols="20"></textarea><iframe ID="Editor" name="Editor" src="../HtmlEditor/index.html?ID=teacher_intro" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:130px;width:100%"></iframe></TD>
      </TR>
      <TR > 
        <TD height=25 colspan="6" align="center"> <input name="submitdd" type="submit" class="Anbut1" value=" 添 加 "> 
          <input name="reset" type="reset" class="Anbut1" value=" 还 原 "> </TD>
      </TR>
    </TBODY>
  </form>
</TABLE>
</body>
</html>
