Jump to content

Help to incorporate recaptcha to existing form


R0CKY

Recommended Posts

Hi

 

Im hoping I can get some help with this - as it is a big problem for me.

 

I am trying to add googles recaptcha code to my existing php page with a comment form...

 

This is the code I have to place before the submit button
 
<button
class="g-recaptcha"
data-sitekey="---deleted----"
data-callback="YourOnSubmitFn">
Submit
</button>
 
 
And This is my current form code from a php file (I've stripped out table layout tags for clarity)
 
 
<form action="{$settings.dburl}/index.php?act=comments&c=post&file={$file.file_id}" method="post">
   {#post_comment#}
   {#poster#
        <input type="text" name="subject" id="subject" size="40" maxlength="150" />
        <textarea name="comment" id="comment" rows="12" style="width: 95%"></textarea>
        <input type="submit" value="{#post_comment#}" onclick="postComment({$file.file_id}); return false;" />
</form>
 
I am confused about what I should replace the YourOnSubmitFn with?
 
Any help would be greatly appreciated. 
 
Edited by R0CKY
Link to comment
Share on other sites

Have you read the documentation? The callback must be a JavaScript function which is called when the user tries to solve the CAPTCHA and has a single parameter for the user's response (g-recaptcha-response). This response must be sent to the server along with the actual form data and then verified.

 

Your system for form submission is rather strange, though, so I cannot comment on how to actually implement the function.

Link to comment
Share on other sites

This is the difficulty I have, I have no php or javascript experience and as you have spotted, I am using a rather old script. I usually muddle through with trial and error, however I am struggling now.

 

I'll figure it out though.

 

Thanks for the pointers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.