PHP code example of andreibu / laravel_captcha
1. Go to this page and download the library: Download andreibu/laravel_captcha library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreibu / laravel_captcha example snippets
CAPTCHA_MIN=[0-999 999 999]
CAPTCHA_MAX=[0-999 999 999]
CAPTCHA_WIDTH=[0-1000]
CAPTCHA_HEIGHT=[0-1000]
CAPTCHA_TIME=[60-3600]
CAPTCHA_GARBAGE=[0-100]
CAPTCHA_REDRAW=[1-10]
CAPTCHA_FONT='/fonts/times.ttf'
{!! Captcha::create_cod(); !!}
or
{!! app('captcha')->create_cod(); !!}
{!! Captcha::create_cod(); !!}
<input name="captcha_md5" type="hidden" value="{!! Captcha::md5(); !!}">
<input name="captcha_cod" type="text" value="">
{!! Captcha::img(); !!}
<div class="pwd_reset_captcha">
@if ($errors->has('captcha_cod'))
<span class="help-block">
<strong>{{ $errors->first('captcha_cod') }}</strong>
</span>
@endif
{!! Captcha::create_cod(); !!}
<input name="captcha_md5" type="hidden" value="{!! Captcha::md5(); !!}">
<input name="captcha_cod" type="text" value="">
{!! Captcha::img(); !!}
<a href="#" onclick="captcha_redraw()">reload</a>
<script>
function captcha_redraw(key){
var key=$('.pwd_reset_captcha input[name=captcha_md5]').val();
$.get('/captcha/'+key,'', function (data){
try{
var json=JSON.parse(data);
$('.pwd_reset_captcha img.captcha').replaceWith(json.img);
if(json.key!=''){$('.pwd_reset_captcha input[name=captcha_md5]').val(json.key);}
}
catch(e){console.log(e);}
});
}
</script>
</div>
$validate = Validator::make(Input::all(), [
'captcha_cod' => '
Route::get('/captcha/{key?}', function($key='') {
$json=array('img'=>Captcha::img($key),'key'=>Captcha::md5());
return json_encode($json);
});