Jump to content

Can't Quite Get Captcha Helper In Code-Igniter Implemented


RalphLeMouf

Recommended Posts

Hey guys -

 

I'm trying to implement my captcha helper in code-igniter. I found a tutorial which is a database free method ( which I prefer ) and seems pretty straight forward. I have checked and my GD library is enabled on my server. I am trying to weave it into my create member script and getting undefined variable errors from the view. However I'm pretty sure there is a hole in logic of implementation.

 

 

 

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();
?>


 

I'm aware of the incompleteness in my view, but that is what I'm having trouble figuring out. How to pass it.

 

Also please not my 'captcha' folder that I have in my root folder is empty and I'm not sure if/or what I should put in there

 

thanks in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.