Spam Helper

The Spam Helper file is extremely easy to use! It returns a random simple question and the correct answer to that question to verify that a user is human. No need to worry about image extensions for captcha images!

Download Spam Helper

Loading this Helper

This helper is loaded using the following code:

$this->load->helper('spam');

The following functions are available:

spam_check()

Lets you fetch a random question and its corresponding answer. Example:

$spam = spam_check();

$question = $spam['question']
$answer = $spam['answer']

usage

So how can I actually use this, you ask? We're assuming you're using the form_helper and input library.. With that said, let's take a look...

$spam = spam_check();

$question = $spam['question'];
$answer = $spam['answer'];

$form  = form_open('submit');
$form .= form_hidden('real_answer', $answer);   // This contatins the real answer
$form .= form_label($question, 'answer');
$form .= form_input('answer');
$form .= form_submit('submit', 'Answer the question!');
$form .= form_close();

// Was the form submitted?
if($this->input->post('answer'))
{
    $user_answer = strtolower($this->input->post('answer'));
    $real_answer = $this->input->post('real_answer');

    // Let's see what's going on
    if($user_answer === $real_answer)
    {
        echo "<h6>Result: Correct!</h6>";
        echo $form;
    }
    else
    {
        echo "<h6>Result: Wrong!</h6>";
        echo $form;
    }
}
else
{
    echo $form;
}

Note: Users' answers are case-insenstive...

Download Spam Helper