PDA

View Full Version : Implementing reCaptcha in UE 3.0.5


sjurick372352
04-24-2009, 06:28 AM
I'm trying to integrate reCaptcha into UE. The first part is easy which requires calling the recaptchalib.php from the form.php page, but I need to know which of the follwing self-generated UE pages is considered the "mail processing" page so I can add the 2nd part of the code to it:

mail_PHP.php
MailFormatting_PHP.php
WAUE_pagename_1.php

Thanks,
Steve

Ray Borduin
04-24-2009, 07:56 AM
You could probably add it to the page where you have applied universal email. I think that would be the processing page.

troyd
08-31-2009, 10:25 PM
Was this ever resolved. I have U.E. working great in a contact form.

And I have reCaptcha working great in a separate version of that form. But when I try to put the two together, things stop working. I am sure I have something in the wrong place, but I can't figure it out.
I've studied both documents and I can't see where I have gone wrong.

There are basically two main parts to the reCaptcha code. The first part they instruct you to put right before the "submit" button. That's easy enough. But the second part they instruct you to make sure is at the very top of the "processing" page. Well, since the form has an action="" then my form's page would be the processing page. But that doesn't work. Neither does putting it at the top of the mail_PHP.php page.

Any advise?

I will gladly post my simple test form code here, but I wasn't sure if it was ok to post code that included the reCaptcha code here as well.

Also, if there is a different captcha technique that has worked better with U.E., I am interested in trying that instead.

Thanks,
TroyD

Ray Borduin
09-01-2009, 07:13 AM
We offer a CAPTCHA solution in our FormBuilder product. The code for it is also part of the Contact Solution. If you own one of those I can describe how to implement it using that code. I am not familiar with reCaptcha, but I imagine it should be possible to do so you are probably missing something simple, but I am not familiar enough to be sure.

troyd
09-01-2009, 11:24 PM
Ray,

Thanks for the reply. I don't own either. I do own the Super Suite, and the User Registration solution. I know that the User Registration solution has a CAPTCHA in it. I thought it was created with extensions within the Super Suite.

Just as an FYI, reCAPTCHA is the latest from the creators of the original CAPTCHA from Carnegie Mellon University http://recaptcha.net/. At least that's how I understand it. I'm not really a big fan of the interface so I don't mind trying something different.

Thanks,
TroyD

Ray Borduin
09-02-2009, 01:30 PM
If you have Form Builder, it will add CAPTCHA to a form.

Otherwise you can just copy and paste the captcha from your User Registration page to another page and use Validation Toolkit to validate it. Depending on when you got the Super Suite you will have one or the other.

Ray Borduin
09-02-2009, 01:30 PM
If you have Form Builder, it will add CAPTCHA to a form.

Otherwise you can just copy and paste the captcha from your User Registration page to another page and use Validation Toolkit to validate it. Depending on when you got the Super Suite you will have one or the other.

troyd
09-02-2009, 01:42 PM
Thanks Ray. I did use the registration page to copy and paste to my contact form. I have captcha and the form working but for some reason if you fill in the form and then type in an incorrect captcha, it erases all that was filled into the form.
I know it's something I did wrong, I'm still studying where the session is not picking up my form.

I've got something in the wrong place, I just don't know what yet.

Thanks
TroyD

Ray Borduin
09-02-2009, 02:02 PM
I bet it is a mismatch in names.

If you update the page name or apply server validation it might update the page reference in the server code, which in turn requires updating the page reference in the value references.

It is a bug of sorts, since the next version of form builder won't ever update the page reference once implemented it won't have the problem. The current version it is easy to get out of synch.

Most likely you should look in your server validation code and find where the page name reference is. Then make sure it is the same on the form itself and find/replace if it isn't.

troyd
09-02-2009, 03:36 PM
Ok, you lost me a little. Are you referring to the session name? On the Users Registration form page the name & id of the form is WAATKRegistrationForm and the session name is WAVT_usersRegistration_Errors and the file name of the form page is users_Registration.php

I'm getting confused because there is an "_" in the page file name and yet this page works great. It keeps the form filled as it should.

On my form I do have all of the names changed to match my form name and page. My form name and id is vendorsform, the session is $_SESSION['WAVT_vendorsform_Errors'] = "";
and the file name of the page is vendorsform.php.

Which part of the above are you referring to?

Thanks,
Troy

Ray Borduin
09-03-2009, 08:21 AM
In the Server Validation code there is a line like this:

PostResult($WAFV_Redirect,$WAFV_Errors,"usersRegistration");


Then each validation reference looks like this:
ValidatedField("usersRegistration","usersRegistration")

or
ValidatedField("usersRegistration","fieldName")

You need to make sure those values match... the argument to PostResults() must match the argument to ValidatedField().

troyd
09-03-2009, 09:48 AM
Ray,

I found this and yes, it seems that I have it correct. Here is that line in my validation code.
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"vendorsform");
}

And my validation show if..
<?php
if (ValidatedField("vendorsform","vendorsform")) {
if ((strpos((",".ValidatedField("vendorsform","vendorsform").","), "," . "7" . ",") !== false || "7" == "")) {
if (!(false)) {
?>
<span class="textfieldServerError" id="Security_codeServerValidation">
Security code did not match image.</span>
<?php //WAFV_Conditional vendorsform.php vendorsform(7:)
}
}
}?>

This validation works but it refreshes my form if it fails.
I only have the one validation right now, and that is the Security_code validation. Could that be my problem? Do I have to validate the entire form fields to store it in the session. (That just occurred to me).

Thanks,
Troy

troyd
09-03-2009, 09:49 AM
Obviously I don't have any smileys in my code. LOL

Troy

Ray Borduin
09-03-2009, 09:57 AM
That looks right. Are they both on the same page or do you have the page submitting to another action page?

Do your show if's work? What is the code you are using for the default value of the text fields?

troyd
09-03-2009, 10:13 AM
Ray,
I think you hit the nail on the head. Since I do not have the other text fields validated, they do not have an initial value. The text field for the CAPTCHA has a value="" just like the sample Users Registration page.

Here is my CAPTCHA text field.
<input name="Security_code" type="text" class="WAATKTextField" id="Security_code" onBlur="if (document.getElementById('Security_codeServerValid ation')) document.getElementById('Security_codeServerValida tion').style.display='none'" value="" size="32" />

So my other text fields have no initial value.
They are just <input name="list_name" type="text" id="list_name" size="32" />

Is that my problem? I will begin validating them now just in case that is the problem. I just didn't think about it because I was so focused on where my typos must be.

Thanks,
Troy

Ray Borduin
09-03-2009, 10:16 AM
You don't need to validate it... you just have to set the value... Validation toolkit stores all the values from the submitted form even if the field isn't actually validated... use something like:


<input name="list_name" type="text" id="list_name" value="<?php echo(ValidatedField("vendorsform","list_name")); ?>" size="32" />

troyd
09-03-2009, 10:42 AM
Amazing Ray, that was it. Thanks.

I do have another small issue adding the values though. All text fields work now, but my textarea field doesn't hold the value in the session. Is there something special I need to do. This text area is a 200 word description and it is the most important field to not have disappear on them after typing it in.

Here is my attempt at adding a value.
<textarea name="description" value="<?php echo(ValidatedField("vendorsform","description")); ?>" cols="50" rows="3" id="description" ></textarea>

I see that Validation tool kit calls it a "Dynamic Attribute". And if I double click on it in the Server Behaviors list and set it VTK removes the ";" after )). But I tried that and it didn't make any difference. And it does that with all of them anyway. Any thoughts?

Thanks,
Troy

Ray Borduin
09-03-2009, 10:54 AM
HTML 101... textareas don't have a value attribute. The value goes between the tags.

<textarea name="description" cols="50" rows="3" id="description" ><?php echo(ValidatedField("vendorsform","description")); ?></textarea>

troyd
09-03-2009, 11:04 AM
Ray,
That was it. And yes, it is HTML 101. I realize that and feel even dumber now.
It's just that sometimes, when I am focused for hours (days) on learning new stuff I overlook the simple stuff I have been doing for years. I can't believe it took me 4 days of scrubbing through the php code only to find that it was a simple HTML issue all along. (I need a nap).

Thanks for the help. I can move on to something else now.

TroyD