2012-08-29 5 views
0

좋아요, 그래서 내 보안 문자 시스템을 만들려고합니다. 두 페이지, 양식 페이지 및 양식 작업이 있습니다. 다음PHP 보안 문자 시스템

<html> 
<head> 
<title>Captcha</title> 
<center> 
<form method="POST" action="captcha.php"> 
<label>Entered Text: </label><input type="text" name="captcha"> 
<input type="submit" name="submit" value="Submit Captcha!"> 
</form> 
</center> 
</head> 
</html> 
<?php 
$firstdigit = rand(1, 9); 
$seconddigit = rand(27, 105); 
$lastdigit = rand(1050, 9515); 
$middle = rand(1000, 20000); 
$captcha = "<b><center><font face=\"Arial\">AX-$firstdigit-X-$seconddigit-K3I$middle-AN3Z-$lastdigit</font></center></b>"; 
echo "$captcha"; 
?> 

및 다음 : 여기 내 코드입니다

<?php 
$captcha2 = $_POST['captcha']; //This is the input field 
$submit = $_POST['submit']; //This is Submit 
if ($submit) { 
    if ($captcha2) { 
    echo "Everything is good."; //Echo'd if everything is good 
    } else { 
    echo "Please fill in all fields."; //Echo'd if $captcha isn't filled out 
    } 
} else { 
echo "Direct access not allowed. Please click submit."; //Echo'd if submit is not pressed, and they access this directly. 
} 
?> 

이 어떻게 다른 폼에서 $의 보안 문자 변수를 타고 captcha.php 페이지에 넣을 수 있습니까? 나는 $의 보안 문자 하나에 넣어 많은 변수를 가지고 생각, 그래서

답변

1

세션을 사용하는 방법 : 세션이 생성 될 때 http://php.net/manual/en/features.sessions.php

는 임의의 문자열을 생성하고 $_SESSION에 저장합니다. 이 값을 사용하여 보안 문자를 그리고 체크하십시오.

+0

이 http://pastebin.com/tnviYStW를 시도했는데 작동하지 않습니다. – user1631702

+0

$ _SESSION 변수를 사용하는 모든 스크립트에서'session_start()'를 사용해야합니다. – Peter

+0

나는이 pastebin.com/tnviYStW를 시도했고, – user1631702