<!--#include file="../checkLogin.asp"-->
<!--#include file="../SQLconn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>保存文件</title>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body  topmargin="5" leftmargin="5">

<p>
<%
Set Upload=Server.createobject("Persits.Upload.1") 
uploadlimitsize=request.cookies("filelength")                             '改变这个设置可以改变上传文件的大小限制，单位兆。
Upload.SetMaxSize uploadlimitsize*1024*1024, True 
Upload.Save  
if err.number <> 0 then 
response.write  "出现错误: " & err.number & "、" & err.description &"" 
end if 
if err.number = 8 then 
response.write " 你上传的文件超过限制（"& uploadlimitsize &"兆）<a href=""javascript:history.go(-1)"">重新上传</a>" 
response.end 
end if 




 
			teacher=Upload.Form("teacher").value
			content=Upload.Form("content").value
			
			
 


      set rscheck=server.createobject("adodb.recordset")
      rscheckSQL="select * from teachers where TName ='"&teacher&"'" 
      rscheck.open rscheckSQL,conn,1,3
	  if  rscheck.eof and  rscheck.bof then
	      response.redirect   "FindError.asp?tname="&teacher
	  end if 
 
      set rsstudent=server.createobject("adodb.recordset")
      rsstudentSQL="select * from students where tongyibianhao='"&request.cookies("tongyibianhao")&"'  and years=(select vname from varset where  name='nowxueqi')" 
      rsstudent.open rsstudentSQL,conn,1,3
	  
	  

		set rszhuti=server.createobject("adodb.recordset")
		rszhutisql="select * from studentBBS where (bid is null)" 
		
		rszhuti.open rszhutisql,conn,1,3
		rszhuti.addnew
		rszhuti("SendTo")=teacher
		rszhuti("content")=content
		rszhuti("tongyibianhao")=request.cookies("tongyibianhao")
		rszhuti("grade")=rsstudent("grade")
		rszhuti("class")=rsstudent("class")
		rszhuti("Studentname")=rsstudent("Uname")
		rszhuti("Studentdatetime")=now()
		strip=Request.ServerVariables("REMOTE_ADDR")
		rszhuti("StudentIp")=strip
		rszhuti("teacher")=""
		
		
		
		rszhuti.update
		rszhuti.close

		Upload.Dispose ' 释放内存 
		Set Upload = Nothing 


 
 response.redirect   "AddBBS.asp"
%>


