<% Option Explicit %>
<%Response.Charset="utf-8"%>

<!--#include file="../Include/ConnSiteData.asp" -->
<!--#include file="../Include/Const.asp" -->

<!--#include file="../Include/Function.asp"-->
<%
dim MesName,Content,SecretFlag,MemID,Linkman,Sex,Company,Address,ZipCode,Telephone,Fax,Mobile,Email,VerifyCode
dim rs,sql
MesName=trim(request.form("MesName"))
Content=request.form("Content")
if trim(request.form("SecretFlag"))="1" then
  SecretFlag=1
else
  SecretFlag=0
end if
MemID=request.QueryString("MemberID")
Linkman=trim(request.form("Linkman"))
Sex=trim(request.form("Sex"))
Company=trim(request.form("Company"))
Address=trim(request.form("Address"))
ZipCode=trim(request.form("ZipCode"))
Telephone=trim(request.form("Telephone"))
Fax=trim(request.form("Fax"))
Mobile=trim(request.form("Mobile"))
Email=trim(request.form("Email"))
VerifyCode=trim(request.form("VerifyCode"))
dim ErrMessage,ErrMsg(7),FindErr(7),i
  ErrMsg(0)="·留言主题必填，长度不能超过100个字符"
  ErrMsg(1)="·留言内容必填，长度不能少于10个字符"
  ErrMsg(2)="·留言人必填，长度不能超过50个字符"
  ErrMsg(3)="·单位名称、地址必填，长度不能超过100个字符"
  ErrMsg(4)="·邮编长度不能超过20个字符"
  ErrMsg(5)="·电话、传真、移动电话长度不能超过50个字符"
  ErrMsg(6)="·电子邮箱格式不正确"
if len(MesName)>100 or len(MesName)=0 then
  FindErr(0)=true
end if  
if len(Content)<5 then
  FindErr(1)=true
end if  
if len(Linkman)>50 or len(Linkman)=0 then
  FindErr(2)=true
end if
if len(Company)>100 or len(Address)>100 then
  FindErr(3)=true
end if
if len(ZipCode)>20 then
  FindErr(4)=true
end if
if len(Telephone)>50 or len(Fax)>50 or len(Mobile)>50 then
  FindErr(5)=true
end if
if not IsValidEmail(Email) then
  FindErr(6)=true
end if
for i = 0 to UBound(FindErr)
  if FindErr(i)=true then
    ErrMessage=ErrMessage+ErrMsg(i)+"<br>"
  end if
next
if not (ErrMessage="" or isnull(ErrMessage)) then
  WriteMsg(ErrMessage)
  response.end
end if
set rs = server.createobject("adodb.recordset")
sql="select * from ameav_Message"
rs.open sql,conn,1,3
rs.addnew
rs("MesName")=StrReplace(MesName)
rs("Content")=StrReplace(Content)
rs("MemID")=MemID
rs("Linkman")=StrReplace(Linkman)
rs("Sex")=Sex
rs("Company")=StrReplace(Company)
rs("Address")=StrReplace(Address)
rs("ZipCode")=StrReplace(ZipCode)
rs("Telephone")=StrReplace(Telephone)
rs("Fax")=StrReplace(Fax)
rs("Mobile")=StrReplace(Mobile)
rs("Email")=Email
rs("SecretFlag")=SecretFlag
rs("AddTime")=now()
rs.update
rs.close
set rs=nothing
WriteMsg("·留言提交成功，点击查看<a href='MessageList.asp'><font color='red'>[留言簿]</font></a>。")
%>