Welcome Guest, Not a member yet? Register   Sign In
flexi auth - A user authentication library for CodeIgniter

[eluser]bunoire14[/eluser]
Hey,

Can anyone help me please! im tearing my hair out! :-D

I am working on a subscription website and have dropped in the Flexi Auth library to handle all my user management needs. I have created a relatively simple registration form and want to implement the reCaptcha library on it. I have managed to get the captcha box to show up on the form, no problems there, and it all seems to submit fine, but every time it submits It fails the captcha required validation.

I have checked the post data and it seems the captcha_response_field isn't being passed as part of the post data so Im wondering what im doing wrong?

I think its got to be something to do with the view... but ill post up my code anyway:

Model: auth/auth_model.php

Code:
$validation_rules = array(
   array('field' => 'register_first_name', 'label' => 'First Name', 'rules' => 'required'),
   array('field' => 'register_last_name', 'label' => 'Last Name', 'rules' => 'required'),
   array('field' => 'register_username', 'label' => 'Username', 'rules' => 'required|min_length[4]|identity_available'),
   array('field' => 'register_email', 'label' => 'Email Address', 'rules' => 'required|valid_email|identity_available'),
   array('field' => 'register_password', 'label' => 'Password', 'rules' => 'required|validate_password'),
   array('field' => 'register_confirm_password', 'label' => 'Confirm Password', 'rules' => 'required|matches[register_password]'),
   array('field' => 'recaptcha_response_field', 'label' => 'Captcha Answer', 'rules' =>'required|validate_recaptcha')
  );
  
  $this->form_validation->set_rules($validation_rules);

Controller: register/register.php

Code:
// Redirect user away from registration page if already logged in.
  if ($this->flexi_auth->is_logged_in())
  {
   redirect('dashboard');
  }
  // If 'Registration' form has been submitted, attempt to register their details as a new account.
  else if ($this->input->post('register_user'))
  {  
   $this->auth_model->register_account();

  }
  

  // Get any status message that may have been set.
  $this->data['message'] = (! isset($this->data['message'])) ? $this->session->flashdata('message') : $this->data['message'];  
  //send recaptcha info
  $this->data['captcha'] = $this->flexi_auth->recaptcha(FALSE);
  //Load the Selected Layout.
  $this->load->view('registration/registration_form', $this->data);

View: registration/registration_form

Code:
<?php echo $this->load->view('global/html_head'); ?>

<div class="span12">
<h1>Registration</h1>
<p>Please fill out the form to register on our system.</p>

<hr />
&lt;?php if (! empty($message) ) {
  echo '
  <div id="messages">
   '.$message.'
  </div>';


  }
  ?&gt;  
</div>

<div class="span6">
&lt;?php

echo form_open(current_url(), 'class="form-horizontal"');
echo form_fieldset('User Information');

  echo '<div class="control-group">';
  echo form_label('First Name', 'register_first_name', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_first_name', set_value('register_first_name'), 'id="register_first_name"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Last Name', 'register_last_name', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_last_name', set_value('register_last_name'), 'id="register_last_name"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Username', 'register_username', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_username', set_value('register_username'), 'id="register_username"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Email', 'register_email', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_email', set_value('register_email'), 'id="register_email"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Choose Password', 'register_password', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_password('register_password', '', 'id="register_password"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Confirm Password', 'register_confrim_password', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_password('register_confirm_password', '', 'id="register_confirm_password"');
  echo '</div></div>';

echo form_fieldset_close();
?&gt;
</div>

<div class="span6">
&lt;?php
  if (isset($captcha))
  {
   echo form_fieldset('reCaptcha - Lets Stop Spam!');
   echo $captcha;
   echo form_fieldset_close();
  }
?&gt;
</div>
<div class="span12">
&lt;?php
echo form_submit('register_user', 'Register', 'class="btn btn-primary"');
echo form_close();
?&gt;
</div>

&lt;?php echo $this->load->view('global/html_footer'); ?&gt;

Any pointers on this would be great, I'm sure I'm missing something simple... but you know how it is sometimes you just cant see it for looking!

Thanks in advance!





Messages In This Thread
flexi auth - A user authentication library for CodeIgniter - by El Forum - 08-08-2013, 03:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB