DMXzone reCAPTCHA Support Product Page

Answered

GOOGLE CONNECTION BUT NO VALIDATION

Asked 01 Dec 2011 15:14:24
1
has this question
01 Dec 2011 15:14:24 John Jackson posted:
I have reCAPTCHA installed on a form and it will change the word combination when I click on the "loop" icon. However, when I click on the form submit button there is no validation of the word combination and the form submission proceeds as if reCAPTCHA is not on the form.

What might I be doing wrong?

Thanks...John

Promoted Answers

Replied 02 Dec 2011 16:10:19
Roger Watkins

If I read you correctly you need summink like this snippet I grabbed from one of the other dmxzone threads (sorry I'm not looking for it again right now).

<?php
if($_SERVER['REQUEST_METHOD'] == "POST") { // if form is submitted
  if (!isset($mm_abort_edit) || !$mm_abort_edit) { // and validation is fine
    $GoTo = "thank_you.php";  // redirect to a new page
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $GoTo .= (strpos($GoTo, '?')) ? "&" : "?";
      $GoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $GoTo));
  }
}
?>


So place that up with your Server Markup code (embedded by the extension) and that will give you the fundamentals for which you refer.

Of course you create your own logic outcomes and then tie that in with your form validation checking. THEN if there are any errors from the capture OR from your validation you redisplay the form as you see fit. Otherwise the form input is processed as expected.

In other words the result...
if (!isset($mm_abort_edit) || !$mm_abort_edit) {

...should be all you need to add some var to your validation function.

Hope that's what you wanted. Regards.

------------------------------------
PS: Edit well here's the link to Teodor's PHP and ASP snippets, so easy.

Edited by - R W on 02 Dec 2011  16:31:08

Replies

Replied 01 Dec 2011 15:24:06
01 Dec 2011 15:24:06 Teodor Kuduschiev replied:
Hi,

Can you please provide a link to your page?
Replied 01 Dec 2011 22:36:53
01 Dec 2011 22:36:53 George Petrov replied:
John,

The form always submits and the CAPTCHA validation is done server side. That is why your form must post to the same page.

It is just shown again when the captcha is not right and all actions like Insert/Update Record are just skipped.

Greetings,
George
Replied 02 Dec 2011 15:01:53
02 Dec 2011 15:01:53 John Jackson replied:
I have updated to 1.0.1 and followed the guidance in the FAQ with same results. Where does the following code go:
if Request.ServerVariables("REQUEST_METHOD" = "POST" then 'if form is submitted
If eval("vartype(MM_abortEdit)" = 0 or (Not MM_abortEdit) Then 'and validated
Response.Redirect "thank_you.asp" 'redirect to a new page
end if
end if

Thanks...John
Replied 02 Dec 2011 15:03:51
02 Dec 2011 15:03:51 John Jackson replied:
I am using DW5 on VISTA SP2 with IE9.

Thanks...John
Replied 02 Dec 2011 15:39:04
02 Dec 2011 15:39:04 Roger Watkins replied:
Hello everyone.

I've got a similar query:

On my current "Contact Us" form the validation, to ensure fields are filled in correctly, takes place "ON SUBMIT" ie. when the "SUBMIT" button is pressed, if the validation procedure fails, the form produces a message to the user to fill it in again.

I can understand the logic of this procedure.

In the case of the reCAPTCHA form, however, whilst I understand how it is generated, I'm not sure how the response (ie. correctly recognised characters or not) is passed to the form to either allow the form to proceed (assuming all validation including reCAPTCHA is met) or, as with the existing validation, it produces some other result.

Is it necessary to trap the result of the reCAPTCHA test or, otherwise, how does the reCAPTCHA control pass either a "pass" or "fail" message back to the form's "ON SUBMIT" procedure?
Replied 02 Dec 2011 16:10:19
02 Dec 2011 16:10:19 R W replied:
Roger Watkins

If I read you correctly you need summink like this snippet I grabbed from one of the other dmxzone threads (sorry I'm not looking for it again right now).

<?php
if($_SERVER['REQUEST_METHOD'] == "POST") { // if form is submitted
  if (!isset($mm_abort_edit) || !$mm_abort_edit) { // and validation is fine
    $GoTo = "thank_you.php";  // redirect to a new page
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $GoTo .= (strpos($GoTo, '?')) ? "&" : "?";
      $GoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $GoTo));
  }
}
?>


So place that up with your Server Markup code (embedded by the extension) and that will give you the fundamentals for which you refer.

Of course you create your own logic outcomes and then tie that in with your form validation checking. THEN if there are any errors from the capture OR from your validation you redisplay the form as you see fit. Otherwise the form input is processed as expected.

In other words the result...
if (!isset($mm_abort_edit) || !$mm_abort_edit) {

...should be all you need to add some var to your validation function.

Hope that's what you wanted. Regards.

------------------------------------
PS: Edit well here's the link to Teodor's PHP and ASP snippets, so easy.

Edited by - R W on 02 Dec 2011  16:31:08
Replied 02 Dec 2011 18:29:47
02 Dec 2011 18:29:47 John Jackson replied:
I had already copied the ASP version on the above code and placed it in my code. I must not have it in the correct location, since I still have the same problem.

Thanks...John
Replied 02 Dec 2011 20:14:56
02 Dec 2011 20:14:56 R W replied:
I don't play? with ASP / NET but I assume the extension plonks its Server Markup code at the top of the script page just like it does mit PHP.

So your snippet, relying on a response (value) from the extension embedded Server Markup has to be just after that; definitely not before.

Only in case of probs, I suggest you prove the concept with just a simple page and form; no other script code or html stuff on the page except perhaps a couple of input boxes and simple code to print the captured POST data stream to the browser when submitted.

Embed the extension's code and add the snippet after that. Keep all that at the top of the script for now.

Make sure the form action cleanly calls the same script (no qstring) and see what transpires. Such a simple clean page without "prettying" it is best for prob debugging.

Fortunately the PHP extension and the snippet work first up.

Hope that helps. Regards.

PS: I also assume you are ONLINE when you test the form!!... otherwise you will get nothing for / from the captcha object; you'll see nada EXCEPT note I did notice a small comment re wrong referrer appear on the page when I at first used the wrong Google hash creds.
Replied 02 Dec 2011 21:19:34
02 Dec 2011 21:19:34 John Jackson replied:
Here's what worked for me:

<%= theCAPTCHA.getControl("red","en" %>
<% if Request.ServerVariables("REQUEST_METHOD" = "POST" then 'if form is submitted
If eval("vartype(MM_abortEdit)" = 0 or (Not MM_abortEdit) Then 'and validated
Response.Redirect "Success.asp" 'redirect to a new page
end if
end if
%>

I do not know why the faces show up in the code.

Thanks for the help...John
Replied 02 Dec 2011 22:26:55
02 Dec 2011 22:26:55 R W replied:
[] At least you're up and running.

It looks like you are placing the snippet below the reCaptcha page object, not at the top of script. After last post I had a quick play as follows.

[8)] ie..
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="ScriptLibrary/dmxReCAPTCHA.asp" -->
<
%Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<
%' DMXzone reCAPTCHA 1.0.1
Dim theCAPTCHA
Set theCAPTCHA = new dmxReCAPTCHA
theCAPTCHA.PrivateKey = "6LdtwcoSAAAAAHKqMCuEp0aWBY1zYj-FO-pYGXDt"
theCAPTCHA.PublicKey = "6LdtwcoSAAAAAL6JNVd0YI9On_1xXabDFMbSsniP"
theCAPTCHA.Construct
%>
<
%if Request.ServerVariables("REQUEST_METHOD") = "POST" then 'if form is submitted
  If eval("vartype(MM_abortEdit)") = 0 or (Not MM_abortEdit) Then 'and validated
    Response.Redirect "thank_you.asp" 'redirect to a new page
  end if
end if 
<
%<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<form action="recapture.asp" method="post">
Name :
<input name="recaptName" type="text">[br]
Message :
<textarea name="recaptMssg" cols="50" rows="8" wrap="virtual"></textarea>[br]

<%= theCAPTCHA.getControl("red","en") %>

<input type="submit" name="submt" id="submt" value="Submit">
<input type="reset" name="rset" id="rset" value="Reset">
</form>
</body>
</html>

That's what I was writing about.

But that's just my untested guess (no IIS asp testing dev serva available).

[] Still why not and you say it works so it might help others struggling over the weekend. Great.

PS EDIT: the "faces" show up 'cause your text happens to include some char combinations that match those parsed for smilies. So where ever you want to post some code samples most forums have a "code" button same as this forum. So marked the code is fully converted to ISO char encoding for html display like mine above. Be well.

Edited by - R W on 02 Dec 2011  22:36:32

Reply to this topic