• Resolved mrcairney

    (@mrcairney)


    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="https://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>

    https://www.ads-software.com/extend/plugins/captcha/

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

    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

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

    what does that even mean? so unclear.

    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.

    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…

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

    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!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Doesn't work on custom form’ is closed to new replies.