PHP

captcha 적용하기

지니 2018. 5. 10. 17:40
반응형

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


원본입니다.  

simple-php-captcha.php 파일은 직접 다운받아 넣으시기 바랍니다.





이를 간단히 비교하는 샘플입니다.


======================================================================


<?php

session_start();

$_SESSION = array();


include("simple-php-captcha.php");

$_SESSION['captcha'] = simple_php_captcha();

//echo print_r($_SESSION['captcha']);


//echo $_SESSION['captcha']['code'];

//echo "<br/><br/>";



?>

<!doctype html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="Generator" content="EditPlus®">

<meta name="Author" content="">

<meta name="Keywords" content="">

<meta name="Description" content="">

<title>Document</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>

</head>

<body>

<script>

var captcha = "<?=$_SESSION['captcha']['code']?>";

function Check(){

//alert(captcha)

//alert($("#passwd").val())

if(captcha== $("#passwd").val()){

alert("일치")

}else{

alert("오류")

}

return;

}

</script>

<img src="<?=$_SESSION['captcha']['image_src']?>" alt="CAPTCHA code">

<br/><br/>

<input type="text" id="passwd" id="passwd">

<button onclick="Check()">검사하기</button>



</body>

</html>



======================================================================



반응형