PHP simple captcha


PHP용 심플 captcha


https://github.com/claviska/simple-php-captcha


thx to Cory LaViska.


   사용법소개



   데모 소스


위의 라이브러리를 가지고 직접 데모를 만들어 보았다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?
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>


   데모 보기






출처: http://serpiko.tistory.com/589 [삽SAP(Study And Programming) 질 블로그. by허정진]

'프로그래밍 > php' 카테고리의 다른 글

PHP Simple HTML DOM Parser  (0) 2018.02.27
정규식 예제  (0) 2018.02.27
컨텐츠 내용중 첫번째 IMG주소 뽑아내기  (0) 2018.02.27
GD  (0) 2018.02.27
날짜 or 시간  (0) 2018.02.27

+ Recent posts