无法在Code-Igniter中获取验证码

时间:2012-11-09 00:34:39

标签: php codeigniter captcha

我仍然是Code-Igniter的新手

我正在尝试在代码点火器中实现我的验证码助手。我找到了一个教程,这是一个免费的数据库方法(我更喜欢),看起来非常简单。我已经检查过,我的GD库在我的服务器上启用了。我试图将它编织到我的创建成员脚本中,并从视图中获取未定义的变量错误。但是我很确定实施逻辑上存在漏洞。

function create_member() 
{
$this->load->library('form_validation');
$this->load->library('session');
$this->form_validation->set_rules('first_name', 'First Name', 'trim|required');
$this->form_validation->set_rules('last_name', 'Last Name', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('password', 'Password', 'trim|required'); 
$this->form_validation->set_rules('password2', 'Confirm Password', 'trim|required|matches[password]');

if($this->input->post() && ($this->input->post('word') == $this->session->userdata('word'))) {



if($this->form_validation->run() == FALSE)
{
$data['main_content'] = 'home/home_page';
$this->load->view('includes/templates/home_page_template', $data);
}
else 
{
$this->load->model('user_model');
if($query = $this->user_model->create_member())
{
$this->load->model('user_model');
$this->varification_email();
$data['main_content'] = 'account/welcome';
$this->load->view('includes/templates/main_page_template', $data);

}
else
{
$this->load->view('home/home_page');
}
}
else {

$this->load->helper('captcha');

$vals = array(
'img_path' => './captcha/',
'img_url' => '/captcha/',
'img_width' => '200',
'img_height' => 30,
'border' => 0,
'expiration' => 7200
);

$cap = create_captcha($vals);
$data['image'] = $cap['image'];
$this->session->set_userdata('word', $cap['word']);
$this->load->view('home/home_page');
}

echo form_open('auth/create_member');

echo form_label('',  'email', array('type'=>'text'));
$data = array( 'name' => 'first_name', 'class' => 'input', 'placeholder' => 'First Name' );
echo form_input($data, set_value('first_name'));
echo "<span class='errors'>";
   echo form_error('first_name');
echo "</span>";

echo form_label('',  'last_name', array('type'=>'text'));
$data = array( 'name' => 'last_name', 'class' => 'input', 'placeholder' => 'Last Name' );
echo form_input($data, set_value('last_name'));
echo "<span class='errors'>";
   echo form_error('last_name');
echo "</span>";

echo form_label('',  'email', array('type'=>'text'));
$data = array( 'name' => 'email', 'class' => 'input', 'placeholder' => 'Email' );
echo form_input($data, set_value('email'));
echo "<span class='errors'>";
   echo form_error('email');
echo "</span>";

echo form_label('',  'password', array('type'=>'password'));
$data = array( 'name' => 'password', 'class' => 'password', 'size' => 30, 'placeholder' => 'Password'  );
echo form_password($data, set_value('sha1(password)'));
echo "<span class='errors'>";
   echo form_error('password');
echo "</span";

echo form_label('',  'password2', array('type'=>'password'));
$data = array( 'name' => 'password2', 'class' => 'input', 'size' => 30, 'placeholder' => 'Confirm Password'  );
echo form_password($data, set_value('sha1(password2)'));
echo "<span class='errors'>";
   echo form_error('password2');
echo "</span>";
echo $image;
echo form_submit('submit', 'Submit');

echo form_close();
?>

我知道我认为不完整,但这就是我弄清楚的问题。如何传递它。

另外请不要我在我的根文件夹中的'captcha'文件夹是空的,我不确定是否/或我应该放在那里

提前致谢

0 个答案:

没有答案