0
我想使用经典ASP的这个例子,但我有2页,一个是表单页面,另一个是验证页面。我是传统ASP中的全新版本,所以我不确定我是否犯了一些语法错误。与经典ASP使用reCAPTCHA
https://developers.google.com/recaptcha/docs/asp
在我的表单页面,我通过JS加载的reCAPTCHA和部分工作正常。在验证页面上,我有下面的代码。
主代码(我删除的东西,从谷歌,我是不会使用像生成与ASP一个验证码表单字段)
recaptcha_challenge_field = Request.Form("recaptcha_challenge_field")
recaptcha_response_field = Request.Form("recaptcha_response_field")
recaptcha_public_key = "hidden" //your public key
recaptcha_private_key = "hidden" //your private key
// returns "" if correct, otherwise it returns the error response
function recaptcha_confirm(rechallenge,reresponse)
Dim VarString
VarString = _
"privatekey=" & recaptcha_private_key & _
"&remoteip=" & Request.ServerVariables("REMOTE_ADDR") & _
"&challenge=" & rechallenge & _
"&response=" & reresponse
Dim objXmlHttp
Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.open "POST", "http://www.google.com/recaptcha/api/verify", False
objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objXmlHttp.send VarString
Dim ResponseString
ResponseString = split(objXmlHttp.responseText, vblf)
Set objXmlHttp = Nothing
if ResponseString(0) = "true" then
'They answered correctly
recaptcha_confirm = ""
else
'They answered incorrectly
recaptcha_confirm = ResponseString(1)
end if
end function
server_response = ""
newCaptcha = True
if (recaptcha_challenge_field <> "" or recaptcha_response_field <> "") then
server_response = recaptcha_confirm(recaptcha_challenge_field, recaptcha_response_field)
newCaptcha = False
end if
这就是我想要检测是否验证码是正确的,但它以任何方式提交表格。
if recaptcha_response_field <> "" AND newCaptcha = False then
// submit form
Else
Response.Write "Error: Please fill out all form fields correctly."
End If
没有你查询Server_response变量,而不是recaptcha_response_field变量?因为recaptcha_response_field与request.form参数匹配,当然是<>“”,因为用户输入了一个值? – ulluoink
我试过,但仍然允许表单提交。 – zen