Image code verification

From e107 Wiki
Jump to: navigation, search

e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page

logo_wiki.png

Current Release 1.0.4 | e107.org | Download | Changelog | Forum | Plugins | Themes | RSS Feed of Latest Changes | Atom Feed of Latest Changes


How to write a plugin
Main page > I : First Aid > II : Development > III : Administration > IV : How To's > V : Plugin Writing > VI : Theming & Shortcodes


Three easy steps to add an Image code verification in your plugin.

1. Create a secure_image object.

Code: include secure_img_handler.php
include_once(e_HANDLER.'secure_img_handler.php');
$sec_img = new secure_image;

2. Add the secure image and input field in your form.

Code: add in html
<input type="hidden" name="rand_num" value="'.$sec_img->random_number.'" />
'.$sec_img->r_image().'<br />
<input class="tbox login verify" type="text" name="code_verify" size="15" maxlength="20" /><br />

3. In your form processing, verify if the code entered by the user is correct.

Code: verify sumited data
if (!$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
{
    $error = true;
    $msg = "Sorry invalid image code.";
}