[eluser]Unknown[/eluser]
Hello everybody
I have the following registration which has to be validated. But no validation happens and the form is submitted no matter what is inputted. No error happens and everything works as if every input is valid.
here is my html markup:
Code:
<div id="main_wrapper" >
<?php
echo form_open('login/validate_new_account');
echo form_input('fullname', 'Fullname');
// this the textfield
echo form_input('email', 'Email Address') ;
// this is the password field
echo form_input('mobile', 'Mobile Number') ;
// this is the password field
echo form_input('username', 'Username');
// this the textfield
echo form_input('password', 'Password') ;
// this is the password field
echo form_input('password_again', 'Password Again') ;
// this is the password-again field
echo form_submit('submit', 'Create Account');
// this is the submit button
echo "<br>";
//echo break tag for the next line
echo anchor('login', "Have an account? Sign in");
// a link to new account page
echo form_close();
?>
<footer><?php echo $div_below_note; ?></footer>
</div>
<div class="error" >
<?php echo validation_errors('<p>', '</p>')?>
<?php if($reg_error != "") { echo $reg_error;} ?>
</div>
Here is my validator function:
Code:
function validate_new_account ()
{
$this->load->library('form_validation');
$this->form_validation->set_rules("fullname", "trim|required|min_length[3]|max_length[64]");
$this->form_validation->set_rules('email', "trim|required|min_length[10]|max_length[64]");
$this->form_validation->set_rules('mobile', "trim|required|exact_length[11]|is_natural");
$this->form_validation->set_rules('username', "trim|required|min_length[3]|max_length[32]");
$this->form_validation->set_rules('password', "trim|required|min_length[6]|max_length[32]");
$this->form_validation->set_rules('password_again', "trim|required|min_length[3]|max_length[64]|matches[password]");
if($this->form_validation->run() === FALSE)
{
$this->register();
}
else
{
// now load the membership model
$this->load->model('membership_model');
// now call the create_new_account function and check the return value
if($result = $this->membership_model->create_account())
{
$this->load->view('members');
}
else
{
$this->register("Registration failed. Please try again.");
}
}
}
}