• Resolved muhajirkhan

    (@muhajirkhan)


    hi,

    i am using your given code in my custom page code,

    <?php if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) echo "Please complete the CAPTCHA." ?>
    
    <?php if( function_exists( 'cptch_display_captcha_custom' ) ) { echo "<input type='hidden' required='required' name='/packages.php' value='true' />"; echo cptch_display_captcha_custom(); } ?>

    its appearing fine, but i need one thing, and i got one error.

    the action which i need to do,
    the captcha’s user input field must be set as required. Currently, my form is submitting the user data without filling the Captcha textbox.

    the Error which i feel and i want to resolve it:
    when i input wrong Captcha in Input field, from submitted. the Captcha Validator should check the correct input Answer.

    how can i solve there two things.

    regards.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter muhajirkhan

    (@muhajirkhan)

    as you can see in above mentioned code, i used “required” but its not working then.

    { echo "<input type='hidden' required='required' name='/packages.php' value='true' />";

    Here’s a working example you may find helpful.

    Thread Starter muhajirkhan

    (@muhajirkhan)

    thanks Chris.

    i just used the following lines, in my custom page, but could not fix the issue

    <div class="wrap">
    					<?php
    						// using Captcha plugin
    						if ( function_exists( 'cptch_display_captcha_custom' ) ) {
    							?><input type="hidden" name="cntctfrm_contact_action" value="true"><?php
    							echo cptch_display_captcha_custom();
    						}
    					?>
    					<?php if ( isset( $errors['captcha'] ) ) : ?>
    					<p><label class="error"><?php echo $errors['captcha']; ?></label></p>
    					<?php endif; ?>
    				</div>

    I’ll be glad to help you figure this out. Instead of posting snippets here, please post your entire page code somewhere like pastebin or codepad or ideone then post a link to it here.

    Hi muhajirkhan,

    In your particular case the following code
    { echo "<input type='hidden' required='required' name='/packages.php' value='true' />";

    will not help you.

    Captcha is not checked, because the following line –
    <?php if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) echo "Please complete the CAPTCHA." ?>

    is inserted in the wrong place.

    Here is the full instruction:

    Please follow the instructions below.
    = I would like to add Captcha to custom form on my website. How can I do this? =
    1. Install the Captcha plugin and activate it.
    2. Open the file with the form (where you would like to add the captcha to).
    3. Find a place to insert the code for the captcha output.
    4. Insert the necessary lines:

    if( function_exists( 'cptch_display_captcha_custom' ) ) { echo "<input type='hidden' name='cntctfrm_contact_action' value='true' />"; echo
    cptch_display_captcha_custom() } ;
    If the form is HTML you should insert the line with the PHP tags:
    <?php if( function_exists( 'cptch_display_captcha_custom' ) ) { echo
    "<input type='hidden' name='cntctfrm_contact_action' value='true'
    />"; echo cptch_display_captcha_custom(); } ?>

    5. Then you should add the lines to the function of the entered data checking
    if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) echo "Please complete the CAPTCHA.
    or
    <?php if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) echo "Please complete the CAPTCHA." ?>
    You could add this line to the variable and display this variable in the
    required place instead of echo "Please complete the CAPTCHA.". If there is a variable (responsible for the errors output) in the check function, this phrase can be added to this variable. If the function returns ‘true’, it means that you have entered captcha properly. In all other cases the function will return ‘false’.

    You can also have a look at the example provided by Chris Dillon, to understand what and where should be inserted.

    Sincerely,
    BestWebSoft Support Team

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘validate the captcha result’ is closed to new replies.