Simple Captcha

  • Posted in : BookCard
  • sermat
    Participant

    Is it possible to add simple captcha to contact form?

    For example 3+4=? is enough i think.

    I have a spam problem.

    Mehmet S.
    Keymaster

    Added to the wp version. It is easy. You can implement it. Are you a coder?

    sermat
    Participant

    I just doing it for hobby. I code html css js etc. I am not backend developer so i don’t know how to code simple captcha in php.

    Please update send-mail.php

    Thanks.

    Mehmet S.
    Keymaster

    You can try Google reCAPTCHA.

    sermat
    Participant

    It seems sucks. I just want same input box with simple captcha. 3+4=? is enough for me. Ty.

    Mehmet S.
    Keymaster

    – open index.html in a code editor.

    – find contact form.

    – add php codes:

    <form id="contact-form" method="post" action="send-mail.php">
    	<input type="hidden" id="to" name="to" value="yourname@yourdomain.com">
    	
    	<p>
    		<label for="name">Name</label>
    		<input type="text" id="name" name="name" class="required">
    	</p>
    	
    	<p>
    		<label for="email">Email</label>
    		<input type="text" id="email" name="email" class="required email">
    	</p>
    	
    	<p>
    		<label for="subject">Subject</label>
    		<input type="text" id="subject" name="subject" class="required">
    	</p>
    	
    	<p>
    		<label for="message">Message</label>
    		<textarea id="message" name="message" class="required"></textarea>
    	</p>
    	
    	<?php
    		$random1 = rand(1, 5);
    		$random2 = rand(1, 5);
    		$sum_random = $random1 + $random2;
    		
    		echo '<p>';
    			echo '<label class="title" for="sum_user">' . $random1 . ' + ' . $random2 . ' = ?</label>';
    			echo '<input type="text" id="sum_user" name="sum_user" class="required" placeholder="What is the sum?">';
    			echo '<input type="hidden" id="sum_random" name="sum_random" value="' . $sum_random . '">';
    		echo '</p>';
    	?>
    	
    	<p>
    		<img class="ajax-loader" alt="Sending ..." src="images/bckg/loader_light.gif">
    		<input type="submit" class="btn submit" value="SEND">
    	</p>
    </form>
    

    – save as index.php

    – download: bookcard-send-mail-php-with-captcha.zip

    sermat
    Participant

    Got it, thanks.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register