PHP Code
$length = 6;
$captcha = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
HTML Code
<input type="text" name="captcha" value="<?php echo $captcha; ?>" id="captcha" />
Enter the code above here :
<input type="password" name="Enter Code" />
Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</td>
JS Code
<script>
function refreshCaptcha()
{
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for(var i=0; i < 6; i++)
{
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
$("#captcha").change().val(text);
}
</script>
Keep Smileing...
nyc tut.., simple and understandable.. :)
ReplyDeletelike also mine. http://pinoysourcecode.blogspot.com/