VBscript problem: how to end if vercode is not 1234

I am new to VBscript so I need help with the following. As you noticed on line 12, vercode is mentioned. I want it to say that if the vercode is not "1234", nothing else will help (ie script completion). Do you know how?

<%@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


a source to share


1 answer


How about aborting the script if vercode is not "1234" you run the interesting part of your script if it is "1234" like below:



<%@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    
%>

      

+1


a source







All Articles