PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of ZLioxygon   ZLy Captcha   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: ZLy Captcha
Generate and validate CAPTCHA images
Author: By
Last change:
Date: 11 years ago
Size: 1,195 bytes
 

Contents

Class file image Download
<?php
require_once('zly_captcha.class.php');
if(
zly_captcha::check()): ?>
<b style="color:green;">Captcha Ok!</b>
<? else: ?>
<b style="color:red;">Captcha Bad!</b>
<? endif; ?>
<form action="" method="POST">
<!-- -->
<div id="captcha_base64" style="display:block;">
<img alt="captcha" src="<?= zly_captcha::image_base64(); ?>" width="150" height="50" />
<div><a href="" id="captcha_switch">can't see image</a></div>
</div>
<!-- -->
<div id="captcha_simple" style="display:none;">
<img alt="captcha" src="zly_captcha.php?i=<?= zly_captcha::salt() ?>" width="150" height="50" />
</div>
<!-- -->
<label for="captcha">captcha</label>
<input type="text" name="captcha" id="captcha" value="" />
<input type="hidden" name="captcha_token" id="captcha_token" value="<?= zly_captcha::token() ?>" />
<input type="submit" />
<!-- -->
<script type="text/javascript">
document.getElementById('captcha_switch').onclick = function(){
    document.getElementById('captcha_base64').style.display = 'none';
    document.getElementById('captcha_simple').style.display = 'block';
    return false;
};
document.getElementById('captcha').focus();
</script>
<!-- -->
</form>