WordPress.org

Ready to get started?Download WordPress

Forums

Captcha
[resolved] Doesn't work on custom form (8 posts)

  1. MrCairney
    Member
    Posted 1 year ago #

    Hi, the plugin displays fine when added to a custom form using the php as suggested in the readme.

    However, filling it out or not doesn't make a difference, the form still sends. I have some custom required fields, what do I need to add to make the captcha challenge the user input? Code is below (site is dev so not live)

    <form id="transportmedia_contact2" method="post" action="/_quickcontact.php">
    
    <div class="frametop_home"></div><!-- end frametop_home-->
        <div class="frame_home line12"><h3>Contact us</h3><br />
    <p>Please fill out this form and one of our consultants will contact you as soon as possible.  <span class="required">*</span> indicates a required field</p>
    
    	<?php 
    
    	if ($_GET[Error] == "Data") { echo '<p class="smallerror">Please verify your data below. Thanks.</p>' ; }
    
    	if ($_GET[NameFormatError] == "100") { echo '<p class="smallerror">Invalid name.</p>' ; $redClass_name = " redFormField"; }
    	if ($_GET[EmailFormatError] == "100") { echo '<p class="smallerror">Invalid email.</p>' ; $redClass_email = " redFormField"; }
    	if ($_GET[PhoneFormatError] == "100") { echo '<p class="smallerror">Invalid phone number.</p>' ; $redClass_phone = " redFormField"; }
    	if ($_GET[CompanyFormatError] == "100") { echo '<p class="smallerror">Invalid company name.</p>' ; $redClass_company = " redFormField"; }
    	if ($_GET[agreementOptionError] == "100") { echo '<p class="smallerror">Please accept the site terms.</p>' ; $redClass_terms = " redFormField"; }
    
    	?>	
    
    <div class="sideform">
    		<div class="form_div">
    		      <label for="c_media">Media</label>
    		      <input type="text" name="c_media" id="c_media" value="<?php print $_GET[c_media] ; ?>" class="formstd" />
    		    </div>
    
    		    <div class="form_div">
    		      <label for="c_loc">Target Area</label>
    		      <input type="text" name="c_loc" id="c_loc" value="<?php print $_GET[c_loc] ; ?>" class="formstd" />
    		    </div>
    
    		    <div class="form_div">
    		      <label for="e_name">Name *</label>
    		      <input type="text" name="e_name" id="e_name" value="<?php print $_GET[e_name] ; ?>" class="formstd<?php print $redClass_name ; ?>" />
    		    </div>
    
    		    <div class="form_div">
    		      <label for="e_email">Email *</label>
    		      <small>Due to the large volume of enquiries we receive, we recommend you use a company email rather than a web provided email address.</small>
    		      <input type="e_email" name="e_email" id="e_email" value="<?php print $_GET[e_email] ; ?>" class="formstd<?php print $redClass_email ; ?>" />
    		    </div>
    
    		    <div class="form_div">
    		      <label for="e_phone">Phone *</label>
    		      <input type="text" name="e_phone" id="e_phone" value="<?php print $_GET[e_phone] ; ?>" class="formstd<?php print $redClass_phone ; ?>" />
    		    </div>
    
    		    <div class="form_div">
    		      <label for="e_company">Company *</label>
    		      <input type="text" name="e_company" id="e_company" value="<?php print $_GET[e_company] ; ?>" class="formstd<?php print $redClass_company ; ?>" />
    		    </div>
    
    			<p>Please note: If you are a student or researcher we cannot offer information regarding advertising. Please contact the <a href="http://www.cim.co.uk/Home.aspx" target="_blank">Chartered Institute of Marketing.</a></p>
    
    			<hr>
    
    			<div class="form_div">
    				<fieldset>
    
    			<?php if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) echo "Please complete the CAPTCHA." ?><br />
    
    			<?php if( function_exists( 'cptch_display_captcha_custom' ) ) { echo "<input type='hidden' name='cntctfrm_contact_action' value='true' />"; echo cptch_display_captcha_custom(); } ?>
    
    			</fieldset>
    	      </div>
    
    			<div class="form_div">
    				<fieldset>
    			        <input type="checkbox" id="fields_agree_terms" name="fields_agree_terms" value="I Agree" class="<?php print $redClass_terms ; ?>" />
    			        <label><span class="required">*</span> I accept the site <a href="/terms-conditions">terms</a> & <a href="/privacy-policy">privacy policy</a></label>
    			</fieldset>
    	      </div>
    
    			<div class="form_div">
    		      <input type="submit" name="Submit" value="Submit">
    		    </div>
    
    		    <div class="form_div"><input type="hidden" name="getsection" value="<?php echo $_SERVER['REQUEST_URI'] ; ?>" /></div>
    			<div class="form_div"><input type="hidden" name="getthispage" value="<?php echo $_SERVER['REQUEST_URI'] ; ?>" /></div>
    
    </div>
    </div><!-- end of frame_home line12 -->
        <div class="framebtm_home"></div><!--end framebtm_home contactform-->
    </form>

    http://wordpress.org/extend/plugins/captcha/

  2. Lock-N-Load
    Member
    Posted 1 year ago #

    Apparently no one knows and the developers never respond so I think we are just SOL as I, and a few others, have the same problem. You posted a month ago and got.. zero response. Horrible support.

  3. bestwebsoft
    Member
    Plugin Author

    Posted 1 year ago #

    Hello MrCairney,

    This line
    <?php if( function_exists( 'cptch_check_custom_form' ) &&
    cptch_check_custom_form() !== true ) echo "Please complete the
    CAPTCHA." ?>
    you should add where you have the fields checking of the existing form.

    Kind regards,
    Support Team

  4. Lock-N-Load
    Member
    Posted 1 year ago #

    "you should add where you have the fields checking of the existing form."

    what does that even mean? so unclear.

  5. TheKillerPenguin
    Member
    Posted 1 year ago #

    I just encountered a similar issue.

    My form was submitting via AJAX, and as not all form values were being passed in the request, it wasn't sending over all the pieces of the Captcha. If you hop into the Captcha source and go to the cptch_check_custom_form() function, it looks for specific params in $_REQUEST. Assuming this is an ajax form submission, you need to make sure all of those are being passed when you submit the form to wherever it's being submitted, or it will always return false.

    cntctfrm_contact_action, cptch_number, and cptch_result are the params you're looking to pass.

  6. tinkerbelle99
    Member
    Posted 1 year ago #

    Hi TheKillerPenguin, I'm having a similar problem with AJAX form integration but just can't seem to figure it out. If you happen to see this, I'd love some more detailed instructions/code examples on how to make this work...

  7. TheKillerPenguin
    Member
    Posted 12 months ago #

    When you open your browser debugger and look at the POST info being sent in the AJAX request, what params are being sent over?

  8. tinkerbelle99
    Member
    Posted 12 months ago #

    Turns out I was just trying the cptch_check_custom_form() at the wrong step in the form validation, oops -- but thanks a lot anyway TheKillerPenguin, I really appreciate your willingness to help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.