セッション クラスとURL ヘルパーは自動ロードされます。
コントローラ:
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->helper('captcha');
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url() . 'captcha/',
'img_width' => '250',
'img_height' => '50');
$cap = create_captcha($vals);
$datacap = array('captcha_time' => $cap['time'], 'word' => $cap['word']);
$this->session->set_userdata($datacap);
$this->form_validation->set_rules('captcha_image', 'Captcha',
'required|callback_captchacheck');
if ($this->form_validation->run() == false)
{
$datatw['image'] = $cap['image'];
$datatw['file_view'] = "register";
$this->load->view('home', $datatw);
} else { // }
折り返し電話:
public function captchacheck($capt)
{
$captss = $this->session->userdata('word');
if ($captss == $capt)
{
return true;
} else
{
$this->form_validation->set_message('captchacheck',
'Security number does not match.');
return false;
}
}
Security number does not match が返されます。
echo $this->session->userdata('word');
貼り付けを表示してコピーしますが、機能しません。
エラーが修正されました!
申し訳ありませんが、私は移動しました:
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url() . 'captcha/',
'img_width' => '250',
'img_height' => '50');
$cap = create_captcha($vals);
$datacap = array('captcha_time' => $cap['time'], 'word' => $cap['word']);
$this->session->set_userdata($datacap);
に:
if ($this->form_validation->run() == false){
//
}
そしてそれはうまくいきました:
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->helper('captcha');
$this->form_validation->set_rules('captcha_image', 'Captcha',
'required|callback_captchacheck');
if ($this->form_validation->run() == false)
{
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url() . 'captcha/',
'img_width' => '250',
'img_height' => '50');
$cap = create_captcha($vals);
$datacap = array('captcha_time' => $cap['time'], 'word' => $cap['word']);
$this->session->set_userdata($datacap);
$datatw['image'] = $cap['image'];
$datatw['file_view'] = "register";
$this->load->view('home', $datatw);
} else
{ }