<!--#include file="dbpath/dbpath.asp"-->
<!--#include file="function/char.inc"-->
<%
sub getInput()
         sName=request.form("Name")
	     sEmail=request.form("Email")
	     sHomePage=request.form("HomePage")
         sOicq=request.form("Oicq")
         sIp=request.ServerVariables("REMOTE_ADDR")
	     sPic=request.form("Pic")
             stxthead=request.form("txthead")
	     sSubject=request.form("Subject")
	     sMemo=request.form("Memo")         
         if soicq="" then soicq="可以不说吗?"
         if sHomePage="" or sHomePage="http://" then sHomePage="还没有呢!"

end sub

Function checkenter()
	If sName="" then
	   checkenter=FALSE
       ErrorMsg="<li>你好像忘了填“昵称”,</li><a href=javascript:history.go(-1)>返回上一页</a>"
	else
	   if sEmail="" or InStr(2,sEmail,"@")=0 then
	      checkenter=FALSE
          ErrorMsg="<li>你的Email有问题请重新填写,</li><a href=javascript:history.go(-1)>返回上一页</a>"
	   else
	      if sPic="" then
		     checkenter=FALSE
             ErrorMsg="<li>你的头像没选,选一个把，</li><a href=javascript:history.go(-1)>返回上一页</a>"
		  else
		     if stxthead="" then
			    checkenter=FALSE
                ErrorMsg="<li>你的表情没选,选一个把，</li><a href=javascript:history.go(-1)>返回上一页</a>"
			 else
			    if sMemo="" or len(trim(sMemo))>250 then
				   checkenter=FALSE
                   ErrorMsg="<li>留言不能为空并且不能超过250字，重新来吧，</li><a href=javascript:history.go(-1)>返回上一页</a>"
				else
	               checkenter=TRUE
				end if
		     end if
		  end if
	   end if	   
	End If
End Function

   dim rs

   dim sName
   dim sEmail
   dim sSubject
   dim sOicq
   dim sIp 
   dim sPic
   dim stxthead
   dim sHomePage
   dim sMemo   
  
   
   dim errorMsg
   dim foundError

   getInput()
   a=checkenter()
   if a = true then
      saveData()
      if foundError=false then
         response.redirect "guest.asp"
      else 
         call showerrors()
      end if
      set rs=nothing  
      conn.close
      set conn=nothing
   else
      call showerrors()
   end if
   

sub saveData()
       dim InsertCursor
       Set InsertCursor = Server.CreateObject("ADODB.Recordset")
       InsertCursor.Open  "select * from book",conn,1,3
       InsertCursor.addnew 
       InsertCursor("name") =htmlencode(sName)
       InsertCursor("email") =htmlencode(sEmail)
       InsertCursor("homepage") =htmlencode(sHomePage)
       InsertCursor("face") ="images/"&sPic&".gif"
InsertCursor("txthead") ="images/"&stxthead&".gif"
       InsertCursor("subject") =htmlencode(sSubject)
       InsertCursor("memo") =htmlencode(sMemo)
       InsertCursor("oicq") =htmlencode(sOicq)        
       InsertCursor("ip") =sIp    
       InsertCursor("time") =cstr(now())
       InsertCursor.Update
       InsertCursor.close
       conn.close
       set InsertCursor=nothing
	   if err>0 then 
	      err.clear
              foundError=true
		  ErrorMsg="<li>数 据 库 操 作 失 败 !</li>"
       else 
       foundError=false
	   end if
   end sub

   sub showErrors()
%>
<html>

<head>
<style type="text/css">
<!-
td{font-size:12px;}
body{font-size:12px;line-height:17px;}
a:link{text-decoration:none;color:#0099CC}
a:visited{text-decoration:none;color:#0099CC}
a:active{text-decoration:none}
a:hover {  color:#0099CC; text-decoration: underline}
->
</style>
<title>3鸟设社∨留言本</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="CSS/Style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#CCCCCC">
<p align="center">留言薄</p>

<p align="center"><span style="font-size: 9pt"><font color="#0080FF"><%=ErrorMsg%></span> </font></p>
</body>
</html> 
<%end sub%>
) 