Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 11th Jul 2014, 12:07 PM   #1
Active Warrior
 
Join Date: 2013
Posts: 70
Thanks: 20
Thanked 2 Times in 2 Posts
Default
Installing recaptcha to my inquiry form
Share on: 
fb share twitter share gplus share more share

I want to install recaptcha to my inquiry form and I need some help with the code.

I'm talking about this recaptcha - https://developers.google.com/recaptcha/docs/php?hl=de

I'm using Wordpress (with my own hosting).

Example page how that "send inquiry" button looks like - http://www.camarocarplace.com/cars/m...vrolet-camaro/

I already added that "recaptchalib.php" file to my theme files and I can access it from my wp panel>editor. However, I don't need to touch it, because I just need to have it there and I need to add that code (in that link, given below "quick start") where my inquiry form is.

As I understand, I need to add this code
Code:
require_once('recaptchalib.php');
  $publickey = "your_public_key"; // you got this from the signup page
  echo recaptcha_get_html($publickey);
to the file where my inquiry form is.

I've found that file and here is the code for that inquiry form (this is the whole code from .php file:
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 <br>";
    echo "To : $to_email  Name : $to_name <br>";
    echo "Subject $subject <br>";
    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);
}
?>
So, I need that captcha to this inquiry form. If you go to that URL above (camaro site) and click on "send inquiry" (red button on the right side), an inquiry form appears. That code above is of that form and I need to add this recaptcha to this form, so that this captcha must be resolved before people can click on "send" button or at least if that captcha isn't resolved correctly, they won't be able to send this form.

Any ideas how to make this work?
Haship is offline  
Unread 11th Jul 2014, 02:02 PM   #2
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: 2011
Location: Rostock, Germany
Posts: 829
Thanks: 106
Thanked 225 Times in 194 Posts
Default
Re: Installing recaptcha to my inquiry form
Share on: 
fb share twitter share gplus share more share

The code is NOT the form code, please provide the <form> code!!!

HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
---
Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu
Michael71 is offline  
Unread 11th Jul 2014, 02:19 PM   #3
Active Warrior
 
Join Date: 2013
Posts: 70
Thanks: 20
Thanked 2 Times in 2 Posts
Default
Re: Installing recaptcha to my inquiry form
Share on: 
fb share twitter share gplus share more share

Originally Posted by Michael71 View Post

The code is NOT the form code, please provide the <form> code!!!

Second code in my first post is the code of my inquiry form. I've copied it from inquiry form .php file.
Haship is offline  
Unread 11th Jul 2014, 02:37 PM   #4
ResponsiveDesignTest.Net
Registered Member
 
Michael71's Avatar
 
Join Date: 2011
Location: Rostock, Germany
Posts: 829
Thanks: 106
Thanked 225 Times in 194 Posts
Default
Re: Installing recaptcha to my inquiry form
Share on: 
fb share twitter share gplus share more share

And where is the <form> tag and the <input> then?

The file you have posted is the file where the data from the form is sent to.

E.g.

Code:
<form action="yourfile.php" method="post">
...
</form>

HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
---
Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu
Michael71 is offline  
Unread 12th Jul 2014, 06:29 AM   #5
Active Warrior
 
Join Date: 2013
Posts: 70
Thanks: 20
Thanked 2 Times in 2 Posts
Default
Re: Installing recaptcha to my inquiry form
Share on: 
fb share twitter share gplus share more share

Oh, so here's the form code. If you need any other codes, please tell me.

Code:
<form method="post" name="agt_mail_agent" id="agt_mail_agent" action="<?php echo get_permalink(); ?>" >
  <input type="hidden" name="pid" id="agt_mail_agent_pid" value="<?php echo ;?>" />
  <input type="hidden" name="sendact" value="send_inqury" />
    <h3><?php echo SEND_INQUIRY;?> </h3>
    <p id="inquiry_send_success" class="sucess_msg" style="display:none;"></p>
    <div class="row  clearfix" ><label><?php _e('Your Name');?> :  <span>*</span></label><input name="inq_name" id="agt_mail_name" type="text"  /><span id="span_agt_mail_name"></span></div>
     <div class="row  clearfix" ><label><?php _e('Email');?> :  <span>*</span></label><input name="inq_email" id="agt_mail_email" type="text"  /><span id="span_agt_mail_email"></span></div>
    <div class="row  clearfix" ><label><?php _e('Contact Info');?> :</label><input name="inq_phone" id="agt_mail_phone" type="text"  /></div>
    <div class="row  clearfix" ><label><?php _e('Comments');?> :  <span>*</span></label>
     <textarea name="inq_msg" id="agt_mail_msg" cols="" rows="" ><?php echo SEND_INQUIRY_SAMPLE_CONTENT;?></textarea>
     <span id="span_agt_mail_msg"></span>
    </div>
    <input name="Send" type="submit"  value="<?php _e('Send');?>" class="button clearfix" />
 </form>
Haship is offline  
Unread 14th Jul 2014, 03:03 PM   #6
Active Warrior
 
Join Date: 2013
Posts: 70
Thanks: 20
Thanked 2 Times in 2 Posts
Default
Re: Installing recaptcha to my inquiry form
Share on: 
fb share twitter share gplus share more share

Actually the full code is here for that form and validation.

Form code:
Code:
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/library/js/inquiry_validation.js"></script>
            
<div id="basic-modal-content2" class="clearfix">
 <form method="post" name="agt_mail_agent" id="agt_mail_agent" action="<?php echo get_permalink(); ?>" >
  <input type="hidden" name="pid" id="agt_mail_agent_pid" value="<?php echo ;?>" />
  <input type="hidden" name="sendact" value="send_inqury" />
    <h3><?php echo SEND_INQUIRY;?> </h3>
    <p id="inquiry_send_success" class="sucess_msg" style="display:none;"></p>
    <div class="row  clearfix" ><label><?php _e('Your Name');?> :  <span>*</span></label><input name="inq_name" id="agt_mail_name" type="text"  /><span id="span_agt_mail_name"></span></div>
     <div class="row  clearfix" ><label><?php _e('Email');?> :  <span>*</span></label><input name="inq_email" id="agt_mail_email" type="text"  /><span id="span_agt_mail_email"></span></div>
    <div class="row  clearfix" ><label><?php _e('Contact Info');?> :</label><input name="inq_phone" id="agt_mail_phone" type="text"  /></div>
    <div class="row  clearfix" ><label><?php _e('Comments');?> :  <span>*</span></label>
     <textarea name="inq_msg" id="agt_mail_msg" cols="" rows="" ><?php echo SEND_INQUIRY_SAMPLE_CONTENT;?></textarea>
     <span id="span_agt_mail_msg"></span>
    </div>
    <input name="Send" type="submit"  value="<?php _e('Send');?>" class="button clearfix" />
 </form>
Validation .js file code:

Code:
$(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 } })})
So where I should add those codes that are in that google page for that recaptcha? I'll add those API keys by myself, I just need to know what codes to add and where. Would be nice if someone could help me. I know it should be simple for someone who knows PHP well. I am kind of a newbie and know only basics, but if I could get the codes and info where to add them, I could do it easily.
Haship is offline  
Closed Thread


Bookmarks

Tags
form, inquiry, installing, recaptcha


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 11:59 PM.