我是VBscript的新手,所以我需要以下帮助。正如您在第12行注意到的那样,提到了vercode。我想在那里声明如果vercode不是“1234”,那么其他任何东西都无济于事(即脚本终止)。你知道吗?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!-- #INCLUDE file="inc/settings.asp" -->
<!-- #INCLUDE file="inc/functions.asp" -->
<!-- #INCLUDE file="inc/db_connect.asp" -->
<%
nameSurname = sqlquote(trim(request.form("name"))) & ""
comment = sqlquote(trim(request.form("comment")) & "")
nid = request.form("nid")
pid = request.form("pid")
comment_date = DatePart("d",now()) & "/" & DatePart("m",now()) & "/" & DatePart("yyyy",now())
if vercode = "1234" then
if nameSurname = "" then nameSurname = "Anonymous" end if
if comment <> "" then
strSQL = "INSERT INTO Comments (fName, Comment, DateSubmitted, NewsID) " &_
"VALUES ('" & nameSurname & "', '" & comment & "', #" & comment_date & "#, " & nid & ");"
con.execute strSQL
con.close
end if
response.redirect("news.asp?NewsID=" & encrypt(nid) & "&PID=" & encrypt(pid) )
%>
答案 0 :(得分:1)
如果vercode不是“1234”而不是终止脚本,如果它等于“1234”,则运行脚本的有趣部分,如下所示:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!-- #INCLUDE file="inc/settings.asp" -->
<!-- #INCLUDE file="inc/functions.asp" -->
<!-- #INCLUDE file="inc/db_connect.asp" -->
<%
nameSurname = sqlquote(trim(request.form("name"))) & ""
comment = sqlquote(trim(request.form("comment")) & "")
nid = request.form("nid")
pid = request.form("pid")
comment_date = DatePart("d",now()) & "/" & DatePart("m",now()) & "/" & DatePart("yyyy",now())
if vercode = "1234" then
if nameSurname = "" then
nameSurname = "Anonymous"
end if
if comment <> "" then
strSQL = "INSERT INTO Comments (fName, Comment, DateSubmitted, NewsID) " &_
"VALUES ('" & nameSurname & "', '" & comment & "', #" & comment_date & "#, " & nid & ");"
'debugging strsql
con.execute strSQL
con.close
end if
response.redirect("news.asp?NewsID=" & encrypt(nid) & "&PID=" & encrypt(pid) )
end if
%>