|
I have sorted it out. It's now working fine.
All I have to do now is work out how to receive an e-mail when someone adds a comment. I am using formmail. I don't know if you have seen this. It's not bad. The only thing is I can't get it to send me an e-mail when someone adds a comment. It's designed for a contact form with hidden fields on the form and redirects the page to the formmail and then to a thankyou page.
Sorry for being a pain.
Thanks for all your help.
This is formmail:
<%@ Language = vbscript%> <%option explicit %> <%server.scripttimeout = 600 %> <% 'declare variables
Dim strFrom, strTo, strSubject, strBody Dim objMessage, objConfig, strServer, intPort Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2 Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok
'############################## CONFIGURATION VARIABLES ####################################
' 'information type and CDOSYS constants '--------------------------------------------------------------------------------------------------- - %> <!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" --> <!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" --> <% '--------------------------------------------------------------------------------------------------- - 'retrieved default fields '--------------------------------------------------------------------------------------------------- - recipient = request("recipient") redirect = request("redirect") subject = request("subject") email = request("email") required = request("required") if required = "" then required = "recipient,subject,email,redirect" else required = "recipient,subject,email,redirect," & required end if
'--------------------------------------------------------------------------------------------------- - 'verify the referer '--------------------------------------------------------------------------------------------------- - referer = request.ServerVariables("HTTP_REFERER") referer = split(referer,"/") url_verified = "no" for icounter = Lbound(url) to Ubound(url) ' if referer(2) = url(icounter) then url_verified = "yes" end if next if not url_verified = "yes" then response.write("The url specified is invalid!") response.End end if
'--------------------------------------------------------------------------------------------------- - 'verify the recipient(not tested) '--------------------------------------------------------------------------------------------------- - 'trimed_referer = split(referer(2),".")' 'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>" 'if trimed_referer(0) = "www" then ' if InStr(1,recipient,trimed_referer(1),1) = 0 then ' response.write "recipient don't match the referer" ' response.end ' end if 'else ' if InStr(1,recipient,trimed_referer(0),1) = 0 then ' response.write "recipient don't match the referer" ' response.end ' end if 'end if
'--------------------------------------------------------------------------------------------------- - 'retrieve form contents and create email fields '--------------------------------------------------------------------------------------------------- - query = Request.ServerVariables("QUERY_STRING") query = split(query,"&") query3 = split(required,",") For iLoop = Lbound(query) to UBound(query) query2 = split(query(iloop),"=") '--------------------------------------------------------------------------------------------------- - 'form validation, checks required fields are not null '--------------------------------------------------------------------------------------------------- - for i = LBound(query3) to UBound(query3) if query3(i) = query2(0) then if query2(1) = "" then response.write ("you must enter a valid ") & query2(0) response.end end if end if 'if query2(0) = "agree" then 'if query2(1) <> "on" or query2(1) = "" then ' response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!") 'response.end 'end if 'end if '--------------------------------------------------------------------------------------------------- - 'form validation, checks a valid email address has been specified '--------------------------------------------------------------------------------------------------- - if query2(0) = "email" then trim(query2(0)) if len(query2(1))<8 then response.Write("You must specify a valid ") & query2(0) response.end end if if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then response.write query2(1) response.Write("You must specify a valid ") & query2(0) response.end end if strEmail1 = split(query2(1),"@") if len(strEmail1(1))<3 then response.Write("You must specify a valid ") & query2(0) response.end end if strEmail2 = split(strEmail1(1),".") if len(strEmail2(0))<3 then response.Write("You must specify a valid ") & query2(0) response.end end if if len(strEmail2(1))<2 then response.Write("You must specify a valid ") & query2(0) response.end end if
|