vbscript - Help Please...

114 views
Skip to first unread message

coolbro

unread,
Jul 15, 2007, 9:52:21 PM7/15/07
to reCAPTCHA
I've unsuccesfully tried to implement reCaptcha on my forum. I can
get the captcha to show, but the message posts whether the correct
words are entered or not. I saw this code from a previous post:

dim objXmlHttp, VarString, ResponseString
VarString = "privatekey=your_private_key" & _
"&remoteip=" & Request.ServerVariables("REMOTE_ADDR")
& _
"&challenge=" &
Request.Form("recaptcha_challenge_field") & _
"&response=" &
Request.Form("recaptcha_response_field")


Set objXmlHttp =
Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.open "POST", "http://api-
verify.recaptcha.net/
verify", False
objXmlHttp.setRequestHeader "Content-Type",
"application/x-www-
form-urlencoded"
objXmlHttp.send VarString
ResponseString = split(objXmlHttp.responseText,
vblf)
Set objXmlHttp = Nothing


if ResponseString(0) = "true" then
'They answered correctly - do something
else
ErrorCode = "&error=" & ResponseString(1)
end if

I'm not exactly sure where to insert this code on my form. The code
for my form is listed here:

<form name="post_mess" method="POST" action="<%=MM_editAction%>">
<table width="500" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#000066" valign="top">
<td colspan="2">
<div align="center"><b><font face="Arial, Helvetica, sans-
serif" size="2" color="#FFFFFF">Post
New Message</font></b></div>
</td>
</tr>
<tr bgcolor="#000066" valign="top">
<td width="94"><b><font face="Arial, Helvetica, sans-serif"
size="2" color="#FFFFFF">Name</font></b></td>
<td width="398">
<input type="text" name="author" size="42">
</td>
</tr>
<tr bgcolor="#000066" valign="top">
<td width="94"><b><font face="Arial, Helvetica, sans-serif"
size="2" color="#FFFFFF">Email
Address </font></b></td>
<td width="398">
<input type="text" name="email" size="42">
</td>
</tr>
<tr bgcolor="#000066" valign="top">
<td width="94"><b><font face="Arial, Helvetica, sans-serif"
size="2" color="#FFFFFF">Subject</font></b></td>
<td width="398">
<input type="text" name="subject" size="42">
</td>
</tr>
<tr bgcolor="#000066" valign="top">
<td width="94"><b><font face="Arial, Helvetica, sans-serif"
size="2" color="#FFFFFF">Message</font></b></td>
<td width="398">
<textarea name="message" cols="36" rows="5"></textarea>
</td>
</tr>
<tr bgcolor="#000066" valign="top">
<td colspan="2">
<div align="center">
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=public key">
</script>

<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=public key"
height="300" width="500" frameborder="0"></iframe>
<br>
<textarea name="recaptcha_challenge_field" cols="40" rows="3"
id="recaptcha_challenge_field">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
<input type="submit" name="Submit" value="Post Message"
onClick="MM_validateForm('author','','R','email','','RisEmail','subject','','R','message','','R');return
document.MM_returnValue">
</div>
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="true">
</form>

jeremyers1

unread,
Jul 16, 2007, 1:47:39 AM7/16/07
to reCAPTCHA
I'm having the same exact problem and my form forllows nearly
identical coding as the html above. The API documentation is no help.

My form is in html, and I cannot find anywhere that gives specific
code on how to implement recaptcha in an .html form.

I'm certainly missing something obvious, so please, treat me like the
coding moron I am, and give me very detailed instructions on what code
to add where.

Thanks!


bgood360

unread,
Jul 19, 2007, 5:34:25 AM7/19/07
to reCAPTCHA
First off, thanks for the code snippet. I think you were about 90% of
the way there, and your effort shaved some time off mine getting this
up and running. Here's my code below, which works. You can see it in
action at http://www.hombrerecords.com/store/guestbook/create.asp .
Below is the code I implemented:

>From the HTML form:

<form id="captcha" name="captcha" method="post"
action="captchaProc.asp">
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<your_public_key>">
</script>
<noscript>
<iframe
src="http://api.recaptcha.net/noscript?k=<your_public_key>"


height="300"
width="500"
frameborder="0">
</iframe><br>

<textarea name="recaptcha_challenge_field" rows="3" cols="40"></


textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>

<input type="submit"/>
</form>

Of course, substitute your own public key for "<your_public_key>".
>From the code that processes this HTML form:

<%
' Test the captcha field
Dim IsGoodCaptcha
IsGoodCaptcha = false

Dim privateKey
privateKey = "<your_private_key>"

Dim VarString
VarString = _
"privatekey=" & privateKey & _


"&remoteip=" & Request.ServerVariables("REMOTE_ADDR") & _
"&challenge=" & Request.Form("recaptcha_challenge_field") & _
"&response=" & Request.Form("recaptcha_response_field")

Dim objXmlHttp


Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")

objXmlHttp.open "POST", "http://api-verify.recaptcha.net/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 - do something

IsGoodCaptcha = true
else
'They answered incorrectly
IsGoodCaptcha = false


ErrorCode = "&error=" & ResponseString(1)
end if

%>

Be sure to replace "<your_private_key>" with your actual private key.

Use the value of isGoodCaptcha to feed an If...Then...Else statement.
For example, if isGoodCaptcha, then let the user do whatever it is
they were trying to do. If isGoodCaptcha is false, then give them an
error message and send them back to try again.

'Hope this helps.
-- Bill Good
http://www.inceptual.com

aemmons

unread,
Jul 20, 2007, 3:10:28 PM7/20/07
to reCAPTCHA
I am having a problem with this bit of code.


VarString = _
"privatekey=" & privateKey & _
"&remoteip=" & Request.ServerVariables("REMOTE_ADDR")
& _
"&challenge=" &
Request.Form("recaptcha_challenge_field") & _
"&response=" &
Request.Form("recaptcha_response_field")

It seems that the reCaptcha widget is not adding the values to the
POST string because Request.Form("recaptcha_challenge_field") and
Request.Form("recaptcha_response_field") have no values. Actually,
they don't even exist in the POST string. Here is what is in my POST
string after submitting the form:

username=admin2&email=&password1=admin&password2=admin

Am I accessing these variables incorrectly? My form is identical to
the one above. Do I have to tell the reCaptcha widget where to put the
values of the variables when a form is submitted? Help Please!

-Andrew

On Jul 19, 2:34 am, bgood360 <billg...@gmail.com> wrote:
> First off, thanks for the code snippet. I think you were about 90% of
> the way there, and your effort shaved some time off mine getting this
> up and running. Here's my code below, which works. You can see it in
> action athttp://www.hombrerecords.com/store/guestbook/create.asp.
> Below is the code I implemented:
>
> >From the HTMLform:
>

> <formid="captcha" name="captcha" method="post"

> Use thevalueof isGoodCaptcha to feed an If...Then...Else statement.

aemmons

unread,
Jul 20, 2007, 3:14:21 PM7/20/07
to reCAPTCHA
O! and also...

If I turn off javascript and force the form to use the <noscript>
widget, then everything works fine. The variables exist like they
should in the POST string.

On Jul 20, 12:10 pm, aemmons <AndrewcEmm...@gmail.com> wrote:
> I am having a problem with this bit of code.
>
> VarString = _
> "privatekey=" & privateKey & _
> "&remoteip=" & Request.ServerVariables("REMOTE_ADDR")
> & _
> "&challenge=" &
> Request.Form("recaptcha_challenge_field") & _
> "&response=" &
> Request.Form("recaptcha_response_field")
>

> It seems that the reCaptcha widget isnotadding the values to the


> POST string because Request.Form("recaptcha_challenge_field") and
> Request.Form("recaptcha_response_field") have no values. Actually,
> they don't even exist in the POST string. Here is what is in my POST
> string after submitting theform:
>
> username=admin2&email=&password1=admin&password2=admin
>

> Am I accessing these variables incorrectly? Myformis identical to


> the one above. Do I have to tell the reCaptcha widget where to put the

> values of the variables when aformis submitted? Help Please!

jigna

unread,
Aug 29, 2007, 8:57:35 AM8/29/07
to reCAPTCHA
Following error comes when I try this code in .net using vb, Any help
appriciated

Server Error in '/WebteamTimetracker' Application.
--------------------------------------------------------------------------------

Unhandled Execution Error
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException:

Source Error:


Line 28: Response.Write(VarString)
Line 29:
Line 30: objXmlHttp.send(VarString)
Line 31:
Line 32:


Source File: C:\Inetpub\wwwroot\WebteamTimetracker
\test_recapcha.aspx.vb Line: 30

JD

unread,
Sep 5, 2007, 2:48:14 PM9/5/07
to reCAPTCHA
Oddly, everything looks great, and there are no errors being returned,
but I'm continually getting a IsGoodCaptcha=false.

Any suggestions?

charle...@cranialherbs.com

unread,
Sep 14, 2007, 9:45:37 AM9/14/07
to reCAPTCHA
I also get the False response using this code, but only from Mozilla
browsers.

Internet Explorer works just fine, though.

Any reason why Mozilla would handle the reCaptcha system differently
than IE?

> > http://www.inceptual.com- Hide quoted text -
>
> - Show quoted text -

reCAPTCHA Support

unread,
Sep 14, 2007, 10:21:08 AM9/14/07
to reca...@googlegroups.com
You may have something like:

<table>
<form>
<tr><td></td>
</tr>
</form>
</table>

When using reCAPTCHA, Firefox parses this according to spec -- it closes the form after seeing the <tr>.

> >                 "&remoteip=" & Request.ServerVariables ("REMOTE_ADDR") & _

> >                 "&challenge=" & Request.Form("recaptcha_challenge_field") & _
> >                 "&response=" & Request.Form ("recaptcha_response_field")



--
reCAPTCHA: stop spam, read books
http://recaptcha.net

charle...@cranialherbs.com

unread,
Sep 17, 2007, 5:25:47 PM9/17/07
to reCAPTCHA
Here's what the webpage code looks like:

<form ...>
<table>
(Some other table rows...)
<tr>
<td width="50%" class="text">
Unique Security Code<br /><span class="smText">Cookies must be
enabled on your web browser to see images.</span></td>
<td width="50%" valign="top"><br>


<script type="text/javascript" src="http://api.recaptcha.net/

challenge?k=<...>">


</script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?

k=<...>"


frameborder="0">
</iframe><br>
<textarea name="recaptcha_challenge_field" rows="3"
cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>

</td></tr>
(Some other table rows...)
</table>
</form>


On Sep 14, 9:21 am, "reCAPTCHA Support" <supp...@recaptcha.net> wrote:
> You may have something like:
>
> <table>
> <form>
> <tr><td></td>
> </tr>
> </form>
> </table>
>
> When using reCAPTCHA, Firefox parses this according to spec -- it closes the
> form after seeing the <tr>.
>

> On 9/14/07, charles.mo...@cranialherbs.com <charles.mo...@cranialherbs.com>

> > > > "&remoteip=" & Request.ServerVariables("REMOTE_ADDR")

> > > > http://www.inceptual.com-Hide quoted text -


>
> > > - Show quoted text -
>
> --

> reCAPTCHA: stop spam, read bookshttp://recaptcha.net- Hide quoted text -
>
> - Show quoted text -Here's what the webpage code looks like:

<form ...>
<table>
(Some other table rows...)
<tr>
<td width="50%" class="text">
Unique Security Code<br /><span class="smText">Cookies must be
enabled on your web browser to see images.</span></td>
<td width="50%" valign="top"><br>


<script type="text/javascript" src="http://api.recaptcha.net/

challenge?k=<...>">


</script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?

k=<...>"


frameborder="0">
</iframe><br>
<textarea name="recaptcha_challenge_field" rows="3"
cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>

</td></tr>
(Some other table rows...)
</table>
</form>

Reply all
Reply to author
Forward
0 new messages