PHP Classes

File: demo/views/index.tpl.php

Recommend this page to a friend!
  Classes of Nikos M.   Simple PHP Captcha Library   demo/views/index.tpl.php   Download  
File: demo/views/index.tpl.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP Captcha Library
Show images to verify humans with math expressions
Author: By
Last change: Update of demo/views/index.tpl.php
Date: 1 year ago
Size: 1,148 bytes
 

Contents

Class file image Download
<?php $this->extend('content.tpl.php'); ?>

<?php $this->start('content'); ?>
<?php tico
()->get('captcha')->reset(); ?>
<p><b>SimpleCaptcha w/ Tico</b> Index page</p>
<form method="post">
<input id="hash" name="hash" type="hidden" value="<?php echo tico()->get('captcha')->getHash(); ?>" />
<label for="answer">Compute the result <img id="captcha" src="<?php echo tico()->get('captcha')->getCaptcha(); ?>" style="display:inline-block;vertical-align:middle" />:</label><a href="javascript:void()" style="display:inline-block;vertical-align:middle;font-size:12px" onclick="return refresh()">(refresh)</a>
<input id="answer" name="answer" type="text" value="" placeholder="result" /><?php if (!empty($msg)) { ?><b><?php echo $msg; ?></b><?php } ?>
<button type="submit">Submit</button>
</form>
<script type="text/javascript">
function refresh()
{
    fetch("<?php echo tico()->uri('/captcha-refresh'); ?>")
    .then(res => res.json())
    .then(res => {
        document.getElementById('hash').value = res.hash;
        document.getElementById('captcha').src = res.captcha;
    })
    ;
    return false;
}
</script>
<?php $this->end('content'); ?>