Need help with recaptcha installation

I am kind of a newbie in all this PHP stuff, but I know the basics. I need a little help (should be very easy for someone who knows PHP well).

I want to add captcha to my submission form, but not sure where to add validation code.

Here is the submission form code:

[code]

<?php echo SEND_INQUIRY;?>

<?php _e('Your Name');?> : *
<?php _e('Email');?> : *
<?php _e('Contact Info');?> :
<?php _e('Comments');?> : * <?php echo SEND_INQUIRY_SAMPLE_CONTENT;?>
[/code]

As I understand I should open that “inquiry_validation.js” and edit it?

I want to add this captcha as found here - https://developers.google.com/recaptcha/docs/php?hl=de

I know it is a simple work, but since I am a newbie in all this, I have some difficulties with it. Would be really nice if someone could help me with it. :slight_smile:

All I need is a confirmation that I should edit that file I’ve mentioned above and what code I should add there. I have two API keys already, So I’ll do that replacement by myself, I just would like to get codes that I need to add to my current form and that .js file.

Here’s the code inside that .js file:

$(document).ready(function(){function u(){if($("#agt_mail_name").val()==""){t.addClass("error");n.text("Please Enter Your Name");n.addClass("message_error2");return false}else{t.removeClass("error");n.text("");n.removeClass("message_error2");return true}}function a(){var e=0;if($("#agt_mail_email").val()==""){e=1}else if($("#agt_mail_email").val()!=""){var t=$("#agt_mail_email").val();var n=/^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;if(n.test(t)){e=0}else{e=1}}if(e){r.addClass("error");i.text("Please Enter valid Email Address");i.addClass("message_error2");return false}else{r.removeClass("error");i.text("");i.removeClass("message_error");return true}}function f(){if($("#agt_mail_msg").val()==""){s.addClass("error");o.text("Please Enter Comments");o.addClass("message_error2");return false}else{s.removeClass("error");o.text("");o.removeClass("message_error2");return true}}function l(){document.getElementById("agt_mail_name").value="";document.getElementById("agt_mail_email").value="";document.getElementById("agt_mail_phone").value="";document.getElementById("agt_mail_msg").value=""}var e=$("#agt_mail_agent");var t=$("#agt_mail_name");var n=$("#span_agt_mail_name");var r=$("#agt_mail_email");var i=$("#span_agt_mail_email");var s=$("#agt_mail_msg");var o=$("#span_agt_mail_msg");t.blur(u);r.blur(a);s.blur(f);t.keyup(u);r.keyup(a);s.keyup(f);e.submit(function(){if(u()&a()&f()){return true}else{return false}})})

Well you haven’t provided any of the validation code so that’s going to be impossible for us to say anything on that. The google code needs to be validated on server side, not in a js script unless that js script is ajaxing to a php validation script, which still means you need to edit the php validation script.

Is it would be possible to make a validation file for just recatpcha? I mean like this there would be 2 validation files, because as I can see from .js code, that’s the validation file for that form.

My form validates if required fields are typed correctly even before someone clicks on “send” button, here’s example page of that - http://www.camarocarplace.com/cars/modified-2010-chevrolet-camaro/ (red button on the right side).

This is another code (where data is sent to).

[code]<?php
if($_POST)
{
$yourname = $_POST[‘inq_name’];
$youremail = $_POST[‘inq_email’];
$inq_phone = $_POST[‘inq_phone’];
$frnd_comments = $_POST[‘inq_msg’];
$pid = $_POST[‘pid’];

$post_title = '<a href="'.get_permalink($post->ID).'">'.$post->post_title.'</a>'; 
$to_name = get_post_meta($post->ID,'name',true);
$to_email = get_post_meta($post->ID,'email',true);
if($to_email=='')
{
	$to_email = get_option('admin_email');	
}
///////Inquiry EMAIL START//////
global $upload_folder_path;
$clientdestinationfile =   get_bloginfo( 'template_directory', 'false' )."/library/notification/send_inquiry.txt";
$message1 = file_get_contents($clientdestinationfile);
$filecontent_arr1 = explode('[SUBJECT-STR]',$message1);
$filecontent_arr2 = explode('[SUBJECT-END]',$filecontent_arr1[1]);
$subject = $filecontent_arr2[0]. __(' for ').'"'.$post->post_title.'"';

$client_message = $filecontent_arr2[1];
$yourname_link = __('<br>From : ').$yourname.__('<br>Phone : ').$inq_phone.'<br><br>Sent from - <b><a href="'.get_option('siteurl').'">'.get_option('blogname').'</a></b>.';
/////////////customer email//////////////
$search_array = array('[#$to_name#]','[#$post_title#]','[#$frnd_subject#]','[#$frnd_comments#]','[#$your_name#]');
$replace_array = array($to_name,$post_title,$frnd_subject,nl2br($frnd_comments),$yourname_link);
$client_message = str_replace($search_array,$replace_array,$client_message);

/* echo "From : $youremail Name : $yourname
";
echo “To : $to_email Name : $to_name
“;
echo “Subject $subject
“;
echo “$client_message”;
exit;*/
if($to_email)
{
sendEmail($youremail,$yourname,$to_email,$to_name,$subject,$client_message,$extra=’’);
}
//////Inquiry EMAIL END////////
$url = get_permalink($post->ID);
if(strstr($url,’?’))
{
$url = $url.”&send_inquiry=success”;
}else
{
$url = $url.”?send_inquiry=success”;
}
wp_redirect($url);
}
?>[/code]

So anyone can help me with this?

At least give me some ideas how I could make this work. :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service