[eluser]Ngulo[/eluser]
hi everyone i'm using these code to do the user registration without 2 distinct views ,but to do all in the same view(Home_view):
controller:
Code:
class Home extends Controller
{
function index()
{
$this->load->helper(array('form','url'));
$this->load->library('Validation');
$rules['username']= "required|min_length[5]|max_length[12]";
$rules['password']= "required|matches[confpassword]";
$rules['confpassword']= "required";
$rules['email'] = "required|valid_email";
$this->validation->set_rules($rules);
$fields['username'] = 'Username';
$fields['password'] = 'Password';
$fields['confpassword'] = 'Password Confirmation';
$fields['email'] = 'Email Address';
$this->validation->set_fields($fields);
if($this->validation->run() == FALSE && isset($fields) )
{$this->load->view('Home_view');}
else{
$data['messaggio_conferma']="registration ok";
$this->load->view('Home_view',$data);
}
}
}
and home_view:
Code:
<?php echo form_open('home');?>
Username
<input type="text" name="username"><br>
<?php echo $this->validation->username_error; ?>
Password
<input type="password" name="password"><br>
<?php echo $this->validation->password_error; ?>
Password Conferma
<input type="password" name="confpassword"><br>
<?php echo $this->validation->confpassword_error; ?>
Email
<input type="text" name="email"><br>
<?php echo $this->validation->email_error; ?>
<input type="submit" name="login" value="login"><br>
<?php if($this->validation->run() == TRUE){echo $messaggio_conferma;}?>
</form>
it works really great
is not definitive code i have to upgrade and i have some questions about it
why does form_validation library doesn't works as the validation one? i can't use that
again, i would like to know how to set my personal error_messages's text for any error input name?
any suggest for my code? do you know a better way to do the registration in the same view page?
thanks to all