저는 폼 + 폼 유효성 검사 클래스를 만들고 있는데, 이것 또한 captcha를 추가하고 싶습니다. captcha 이미지가 표시되지만 $ _SESSION에 아무 것도 저장하지 않습니다. https://github.com/gesf/captcha.class.php
지금 내 컨트롤러에서 나는이 사용 :
나는이 보안 문자 스크립트를 사용하고
$data['regform']->addfield('user_captcha', 'Human verification', 'captcha', 'captcha');
을 그리고 그 다음 생성
<label>
<span>Human verification</span>
<img name="user_captcha" src="http://www.websiteurl.com/dev/misc/captcha.php?c=1"><input type="text" name="user_captcha" value="" />
</label>
이미지 해야하는 것처럼 보여주고 있습니다. 그러나 세션에 쓰지 않기 때문에 입력을 검증 할 수 없습니다. 이제 이미지 파일 captcha.php에서이 클래스 보안 문자를로드하고이 클래스의 생성자에서이 세션에 쓰려고 :
function Captcha($letter = '', $case = 5) {
$this->_capCase = $case;
if (empty($letter)) {
$this->StringGen();
} else {
$this->_capLength = strlen($letter);
$this->_capString = substr($letter, 0, $this->_capLength);
}
@session_start();
$_SESSION['asd'] = 'asd';
$_SESSION["CAPTCHA_HASH"] = sha1($this->_capString);
$this->SendHeader();
$this->MakeCaptcha();
}
내 세션은 항상 빈 유지됩니다. 하지만 다음을 시도해보십시오.
<?php $_SESSION['bleh'] = 'asd'?>
<?php echo $form; ?>
세션에 'bleh'를 추가해야합니다. 이 세션에 쓸 이유
정말
누군가가 나를 도울 수 ... 볼 수 없습니다?
감사합니다.
응용 프로그램에서 항상 session_start()를 호출합니까? –
예 내 index.php 파일에 session_start가 있습니다. –