add.asp
来自「计算器源码」· ASP 代码 · 共 102 行
ASP
102 行
<!--#include file="conn.asp" -->
<%
dim rs3
dim sql3
dim name,email,homepage,oicq,content,face,dateandtime,ip
set rs3=server.CreateObject("adodb.recordset")
sql3="select * from message"
rs3.open sql3,conn,3,2
name=left(trim(request.Form("name")),14)
email=left(trim(request.Form("email")),30)
homepage=left(trim(request.Form("homepage")),50)
oicq=left(trim(request.Form("oicq")),12)
content=server.HTMLEncode(trim(request.Form("content")))
face=trim(request.Form("face"))
ip=request.ServerVariables("REMOTE_ADDR")
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
if name="" then
name="匿名人士"
end if
if email=""or not IsValidEmail(email) then
email="不告诉你"
end if
if homepage="" then
homepage="我不想写"
end if
if oicq="" or not IsNumeric(oicq) then
oicq="保密"
end if
if content="" then
response.Write "您什么也没写,这可不行!"
response.end
end if
if face="" then
face="image/face7.gif"
end if
rs3.addnew
rs3("name")=name
rs3("email")=email
rs3("homepage")=homepage
rs3("oicq")=oicq
rs3("content")=content
rs3("face")=face
rs3("ip")=ip
rs3("dateandtime")=now()
rs3.update
rs3.close
set rs3=nothing
response.redirect("index.asp")
response.End
conn.close
set conn=nothing
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?