0

I have a blog for my official website. I allow people for commenting on my blog but i don't want to get comment from auto-bot. Therefore, i am thinking of to add an extra field which is called "security question" to the comment form. But i don't know how to make it work.

This is the code i have for processing my existing contact form. (contact_info_submit.php)

<?php

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$location = $_POST['location'];
$purpose = $_POST['purpose'];
$status = $_POST['status'];
$findus = $_POST['findus'];
$inquiry = $_POST['inquiry'];
$security = $_POST['security'];
$from = "JT Design";
$to = "inquiry@jtdesign.my";
$subject = "$from, $name has submitted the enquiry form.";
$message = "Hi $from,\n$name has submitted the enquiry form. Details are as follow: \n\n/*** Form Details Begin ***/\n\nName: $name\nPhone Number: $phone\nEmail Address: $email\nLocation: $location\nContact Purpose: $purpose\nHouse Status: $status\nHow did visitor find us?: $findus\nMessage: $inquiry\n\n/*** Form Details Ended ***/\n\nPlease response to $name as soon as possible.\n\nRegards,\n$from";

if ($security=="17") {
   mail($to, $subject, $message, "From: JTDesiGn");
   header("Location:/thanks.php");
}

else {
   header("Location:/enquiry-form/?Submission=failed");
}
?>

Url to see my online enquiry form: www.jtdesign.my/enquiry-form/

Any solution to apply this code to wordpress comment form? I want to add the "security" field only.

-1

Use this SI CAPTCHA Anti-Spam plugin, may be helpful to you

https://wordpress.org/plugins/si-captcha-for-wordpress/screenshots/

  • 1
    My blog has a lot of plugins already. I try not to use plugin for this. Any solution to make this work? – Jornes Jan 2 '15 at 7:50
  • plugin is dead.... – Mark Kaplun Jan 18 '18 at 7:29
-1

Here is exmaple code,You will change as per your requirement

Put this in your HTML

<INPUT class="input" type="text" name="vercode" value="" required>                                     
<img src="captcha.php" style="margin:3px 0px; width:110px; height:34px">

Create Captcha File captcha.php

<?php 
session_start(); 
$text = rand(10000,99999); 
$_SESSION["vercode"] = $text; 

$image = imagecreatefromjpeg("images/bg.jpg");
$txtColor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 5, 5, $text, $txtColor);
header("Content-type: image/jpeg");
imagejpeg($image);
?>

than use this code

<?php 
session_start(); 
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  { 

     echo  '<strong>Incorrect verification code...</strong>'; 
}
else
{
    $name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$location = $_POST['location'];
$purpose = $_POST['purpose'];
$status = $_POST['status'];
$findus = $_POST['findus'];
$inquiry = $_POST['inquiry'];
$from = "JT Design";
$to = "inquiry@jtdesign.my";
$subject = "$from, $name has submitted the enquiry form.";
$message = "Hi $from,\n$name has submitted the enquiry form. Details are as follow: \n\n/*** Form Details Begin ***/\n\nName: $name\nPhone Number: $phone\nEmail Address: $email\nLocation: $location\nContact Purpose: $purpose\nHouse Status: $status\nHow did visitor find us?: $findus\nMessage: $inquiry\n\n/*** Form Details Ended ***/\n\nPlease response to $name as soon as possible.\n\nRegards,\n$from";

if ($security=="17") {
   mail($to, $subject, $message, "From: JTDesiGn");
   header("Location:/thanks.php");
}

else {
   header("Location:/enquiry-form/?Submission=failed");
}
}
?>
  • Hi Nkuldip! Thanks for your suggested coding. But, how do i add it to my wordpress comment form? I don't really know how to do it. – Jornes Jan 4 '15 at 16:51
  • this is just wrong, this is not how you handle comment submission. – Mark Kaplun Jan 18 '18 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.