티스토리 뷰
PHP simple captcha
PHP용 심플 captcha
https://github.com/claviska/simple-php-captcha
thx to Cory LaViska.
사용법소개
데모 소스
위의 라이브러리를 가지고 직접 데모를 만들어 보았다.
<?
session_start();
include("simple-php-captcha.php");
$PREV_Captcha = $_SESSION['captcha']['code'];
$POST_Captcha = $_POST['captcha'];
if ( !empty($PREV_Captcha) && !empty($POST_Captcha) )
{
if( strcasecmp($PREV_Captcha, $POST_Captcha) != 0 )
{
echo "<script>alert('이미지에 출력된 글자와 다릅니다.');</script>";
}else{
echo "<script>alert('정상');</script>";
}
}//end if
$_SESSION['captcha'] = simple_php_captcha();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- meta -->
<meta name="Author" content="serpiko@hanmail.net" />
<meta name="description" content="http://serpiko.tistory.com" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="format-detection" content="telephone=no" />
<!-- link -->
<link rel="stylesheet" type="text/css" href="" />
<!-- script -->
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<title>Document</title>
<style>
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
</style>
</head>
<body>
<div id="wrap">
<form method='post' action='<?=$PHP_SELF?>'>
PREV_Captcha : <input type='text' size='100' value='<?=$PREV_Captcha?>' /> <br />
POST_Captcha : <input type='text' name='' size='100' value='<?=$POST_Captcha?>' /> <br /><br />
할당된 캡챠<br />
<img src="<?=$_SESSION['captcha']['image_src']?>" style='width:100px;border:1px solid blue;border-radius:7px;' /><br /><br />
사용자 캡챠 입력<br />
captcha : <input type='text' size='100' name='captcha' value="" /> <br />
<button type='submit'>확인</button>
</form>
</div>
</body>
</html>
데모 보기
'■ 백엔드 ■ > PHP' 카테고리의 다른 글
| PHP - PHPExcel 에서 Dropdown 리스트 생성하기 (0) | 2017.05.31 |
|---|---|
| jpgraph - php graph to image (0) | 2017.04.18 |
| PHP 세션 값 오류의 원인 (0) | 2015.06.18 |
| rand( [int $min, int $max] ) (0) | 2015.03.03 |
| 클라이언트 소켓 함수 (0) | 2015.02.04 |
댓글