Welcome Guest, Not a member yet? Register   Sign In
Registration issue
#1

Hello people!

First wanna to say I'm new on this forum as well as in coding so please be plecable.

I've got a problem with my registration form.

My view looks like this:


<?php echo validation_errors(); ?>
<form method='post'>
mail: <input type="text" name="mail" value="<?php echo set_value('mail'); ?>"/></br>
passwd: <input type="text" name="password" value="<?php echo set_value('password'); ?>"/></br>
conf: <input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>"/></br>
<input type="submit" value='send'/>

</form>

My controller looks like this:

<?php

class Zarejestruj extends CI_Controller
{
public function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');

$this->form_validation->set_rules('mail', 'Email', 'required|valid_email|is_unique[user.mail]');
$this->form_validation->set_rules('password', 'Password', 'required',
array('required' => 'You must provide a %s.'));
$this->form_validation->set_rules('passconf', 'Password confirmation', 'required|matches[password]');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('register');
}
else
{
$this->load->view('success');
}

}



}

and db settings like this:

$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'beta',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

So, my problem is in submiting the data. At the moment I wan to check if the validation is success, I see that the mail field is not unique. Database table user is empty.

What's the matter?
Reply
#2

Is the database class actually loaded/initialized before the validation is run? The is_unique() method of the CI_Form_validation library returns false if $this->CI->db is not available.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB