Det kunne være at du måske skulle have hele koden og se, så her er den:
<!--#include file="debug.asp"-->
<%
'bnbform.asp
'(c)1999 freeasp.Com
'No warranties, etc.. Gratis for your learning and any other
'experience you might need it for!
'Version 0.99 April 1, 1999
'''''''''''''' SPECIAL FORM VARIABLES ''''''''''''''''''''''''''''
'required: comma delimited list of required entry fields
'data_order: comma delimited list indicating what fields to actually
' print and in what order.
'outputfile: the name of the file to save the data in if using a file
'emailfile: the name of the file to hold only the sender e-mail address
'ok_url: URL to go to if successful
'not_ok_url URL to go to if unsuccessful
'submit_to: email address of person to input receive data by mail
'cc_to: email address of Cc Recipient
'submit_by: email address of person completing form
'autorespond: if yes, then send confirmation to submitter
'automessage: text to print for autoconfirmation e-mail
'form_id: name of form for e-mail subject
'okaydomains: prevents calling the script from other sites,
' without restricting e-mail addresses.
' replaces $SECURE_NAME from earlier versions.
' use only lower case letters.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' MAIN ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Reading, writing, appending constants
ForReading = 1
ForWriting = 2
ForAppending = 8
'Where to save the email and output log file relative to web server root
Filebase = Server.MapPath(".")
okaydomains = split("
www.annassexshop.dk|www.1stchoice.dk|www.internetklubben.dk|www2.annassexshop.dk", "|", -1, vbtextcompare)
'Global Variables
Dim sortlist, mandatory, shtml
Dim debug
' set debug = false to turn off debugging info
' to see the debug print out info, comment out the thankyou and redirect statement
debug = false
if valid_page then
decode_vars
if valid_data then
if write_data then
if (Request.Form("autorespond") = "yes") then
answer_back
end if
if (Request.Form("ok_url") <> "") then
msginfo("shtml is " & shtml)
Response.Redirect Request.Form("ok_url")
else
msginfo("shtml is " & shtml)
thank_you
end if
end if
end if
else
Response.Write "Sorry...Cant run from here!"
Response.End
end if
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function write_data()
Set fso = Server.CreateObject("Scripting.FilesystemObject")
if Request.Form("submit_by") <> "" then
if not valid_address then
bad_email
Set fso = nothing
write_data = false
exit function
end if
end if
if Request.Form("submit_by") <> "" and Request.Form("emailfile") <> "" then
Set f = fso.OpenTextFile(Filebase & "\" & Request.Form("emailfile"), ForAppending, true)
f.writeline Request.Form("submit_by")
f.close
Set f = nothing
end if
if Request.Form("submit_to") <> "" then
sTo = Request.Form("submit_to")
sFrom = Request.Form("submit_by")
sSubject = Request.Form("form_id") & " Response"
if Request.Form("cc_to") <> "" & Request.Form("submit_to") <> "" then
sCc = Request.Form("cc_to")
end if
sBody = "The following information was submitted: " & vbCrlf _
& "Host: " & Request.ServerVariables("REMOTE_HOST") & vbCrlf
end if
msginfo("The output file is " & Filebase & "\" & Request.Form("outputfile") & "!")
if Request.Form("outputfile") <> "" then
msginfo("Open outputfile")
Set f = fso.OpenTextFile(Filebase & "\" & Request.Form("outputfile"), ForAppending, true)
end if
for i = 0 to Ubound(sortlist)
if Request.Form("outputfile") <> "" then
msginfo("Write content into output file: " & sortlist(i))
msginfo("Write content into output file: " & Request.form(sortlist(i)))
f.writeline sortlist(i) & " = " & Request.Form(sortlist(i))
end if
if Request.Form("submit_to") <> "" then
sBody = sBody & sortlist(i) & " = " & Request.Form(sortlist(i)) & vbCrlf
end if
next
if Request.Form("outputfile") <> "" then
f.writeline now
f.close
end if
Set fso = nothing
msginfo("Mail is sent")
if SendMail (sFrom, sTo, sSubject, sBody, sCc, sBcc, iPriority) then
write_data = true
else
write_data = false
shtml = "<H1>Send mail fails for some reason!</H1>"
end if
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub decode_vars()
For each Item in Request.Form
if Item = "data_order" then
sortlist = split(Request.Form(item), ",", -1, vbtextcompare)
end if
if Item = "required" then
mandatory = split(Request.Form(item), ",", -1, vbtextcompare)
end if
next
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function valid_data ()
if Request.Form("data_order") = "" then
shtml = "<H1>NO data_order list SPECIFIED!</h1>"
valid_data = false
exit function
end if
for i = 0 to Ubound(mandatory) 'Test all required fields, bail on 1st bad
if Request.Form(mandatory(i)) = "" then
if Request.Form("not_ok_url") <> "" then
Response.Redirect Request.Form("not_ok_url")
exit function
else
try_again
valid_data = false
exit function
end if
end if
next
valid_data = true
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub thank_you ()
shtml = "<H1>Thank you!</H1>" & _
" Your information has been sent and I will be in touch " & _
" with you soon."
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub try_again ()
shtml = "<H1>Missing Data!</H1>" & _
"<B>Please press the back button and fill in" & _
"all required fields!<P></B>"
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub answer_back ()
if Request.Form("automessage") <> "" then
ansmsg = Request.Form("automessage")
else
ansmsg = "Thank you for your submission. I will be" & _
"getting in touch with you soon."
end if
sFrom = Request.Form("submit_to")
sTo = Request.Form("submit_by")
sBody = ansmsg
sCc = ""
sBcc = ""
iPriority = 1
sSubject = "Thank you"
SendMail sFrom, sTo, sSubject, sBody, sCc, sBcc, iPriority
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function valid_address ()
testmail = Request.Form("submit_by")
msginfo("The submitter's email is " & testmail)
if mailpattern(testmail) then
valid_address = true
else
valid_address = false
end if
end function
function mailpattern(email)
Dim i,j, first, last, char
i = instr(1, email, "@", vbtextcompare)
msginfo("The @ is at position " & i)
if i > 0 and i < len(email) then
first = left(email, i - 1)
last = mid(email, i+1, len(email))
else
mailpattern = false
exit function
end if
i = 0
do until i = len(first)
i = i + 1
char = mid(first, i, 1)
msginfo("The asc char is " & asc(char))
' if char is not in [.z-aA-Z0-9]
if asc(char) <> 46 and (asc(46) < 48 or asc(char) > 57) and _
(asc(char) < 65 or asc(char) > 90) and (asc(char) < 97 or asc(char) > 122) then
mailpattern = false
exit function
end if
loop
i = 0
do until i = len(last)
i = i + 1
char = mid(last, i, 1)
' if char is not in [.z-aA-Z0-9]
if asc(char) <> 46 and (asc(46) < 48 or asc(char) > 57) and _
(asc(char) < 65 or asc(char) > 90) and (asc(char) < 97 or asc(char) > 122) then
mailpattern = false
exit function
end if
loop
mailpattern = true
end function
sub bad_email ()
shtml = "<FONT SIZE=""+1""><B>" & _
"SORRY! Your request could not be processed because of an" & _
"improperly formatted e-mail address. Please use your browser's " & _
"back button to return to the form entry page.</B></FONT>"
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' If you don't care people link your script take of the valid_address
' in the begining
function valid_page ()
domain_ok = false
rf = Request.ServerVariables("HTTP_REFERER")
for i = 0 to Ubound(okaydomains)
if instr(1, rf, okaydomains(i), vbtextcompare) > 0 then
valid_page = true
exit function
end if
next
valid_page = false
end function
function SendMail (sFrom, sTo, sSubject, sBody, sCc, sBcc, iPriority)
Set JMail = Server.CreateObject("JMail.SMTPMail")
Jmail.ContentType = "text/html"
JMail.ServerAddress = "mail.annassexshop.dk"
JMail.Charset = "iso-8859-1"
JMail.ContentTransferEncoding = "8bit"
JMail.SenderName = "Artemis"
JMail.Sender = sFrom
JMail.Subject = sSubject
JMail.AddRecipient sTo
JMail.Body = sBody
JMail.Priority = iPriority
JMail.Execute
set JMail = nothing
end function
%>
<% = shtml %>