Print This Page




qEngine supports captcha in three easy steps:

  1. Call qvc_init () to initiliaze qvc (qVisual Confirmation aka captcha).
  2. Display the captcha in the form.
  3. Compare user input captcha against stored value. If they are different, then user must re-enter the captcha.
function qvc_init ($num = 5)

Use this function to initialize qvc. $num is the number of digit to display, default is 5 digits.

function qvc_value ()

Use this function to call stored qvc value. qvc value is stored in user's cookies, encrypted by sha1(). Please remember, user input must be encrypted by sha1 before comparing!

To display the captcha image, use:

<img src="visual.php" alt="captcha" />

Example 1. test.php

require './includes/user_init.php';

$cmd = post_param ('cmd');

switch ($cmd)
    case 'process':
        $name = post_param ('name');
        $qvc = post_param ('qvc');
        // sha1 user input before comparing!
        if (sha1 ($qvc) != qvc_value()) msg_die ('echo', 'Invalid Captcha!');
        msg_die ('echo', 'Your name is '.$name);
        qvc_init ();
        $tpl = load_tpl ('test.tpl');
        $txt['main_body'] = quick_tpl ($tpl, $txt);
        flush_tpl ();


<h1>Welcome to test page!</h1>
<form name="myform" action="test.php" method="post">
    <input type="hidden" name="cmd" value="process" />
    <p>Your name: <input type="text" name="name" /></p>
    <p>Captha: <img src="visual.php" alt="captcha" />
       <input type="text" name="qvc" /></p>
    <p><input type="submit" /></p>

Posted On: Aug-26-2010 @ 07:00am
Last Updated: Jan-01-1970 @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own

Powered by qEngine
Generated in 0.009 second | 15 queries