<%
'主判断
errorflag=0
errorflag=Request("errorflag")
'调试语句response.write Request.ServerVariables("REQUEST_METHOD")
'调试语句response.write "error"&errorflag
IF Request.ServerVariables("REQUEST_METHOD")="POST" THEN
'调试语句response.write "in"&errorflag
flag=0
mysubject=Request.form("mysubject")
mycontent=Request.form("mycontent")
if mysubject="" then
if mycontent="" then
flag=3
else
flag=1
end if
else
if mycontent="" then
flag=2
end if
end if
Select case flag
case 1
Response.Redirect("guestbook.html?errorflag=1")
case 2
Response.Redirect("guestbook.html?errorflag=2")
case 3
Response.Redirect("guestbook.html?errorflag=3")
case else
errorflag=0
end Select
myname=Request.form("myname")
mygender=Request.form("mygender")
myemail=Request.form("myemail")
myhomepage=Request.form("myhomepage")
mypsw=Request.form("mypsw")
mynow=now
myip=request.ServerVariables("REMOTE_ADDR")
if myname="" then myname="guest"
if mygender="" then mygender="女"
if myemail="" then myemail="他很狡猾,居然没有留"
if myhomepage="" or myhomepage="http://" then myhomepage="Nothing"
if mypsw="" then mypsw="guest"
if mynow="" then mynow="3000年"
if myip="" then myip="0.0.0.0"
addsql1="Insert into table1(tname,tgender,temail,tnow,thomepage,tsubject,tcontent,tip) values ('"
addsql1=addsql1&myname&"','"&mygender&"','"&myemail&"','"&mynow&"','"&myhomepage&"','"&mysubject&"','"&mycontent&"','"&myip&"')"
addsql2="Insert into table2(tname,tpsw) values ('"&myname&"','"&mypsw&"')"
checksql="Select tname from Table2 where tname='"&myname&"' and tpsw='"&mypsw&"'"
Set conn=Server.CreateObject("Adodb.Connection")
DBPath=Server.MapPath("db1.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="&DBPath
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open checksql,conn,1,1
if rs.Bof and rs.Eof then
conn.Execute addsql2
else
end if
conn.Execute addsql1
rs.close
conn.close
Response.redirect("indexly.asp")
ELSE
%>
<% END IF %>