I just started learning how to use CodeIgniter and never use the framework before, so I only know a little about how to stream. Right now I have 1 problem that I want to set the input username to lowercase and I don’t know how to write a function for convert_lowercase ().
Below is my code:
public function signup_validation()
{
$this ->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|trim|is_unique[userinfo.username]|convert_lowercase');
$this->form_validation->set_rules('password', 'Password', 'required|trim');
$this->form_validation->set_rules('cpassword', 'Confirm Password', 'required|trim|matches[password]');
$this->form_validation->set_message('is_unique', 'That Username Already Exists.');
if($this->form_validation->run()){
}else{
$this->load->view('signup');
}
}
public function convert_lowercase()
{
strtolower($this->input->post('username'));
}
I'm not sure I'm doing the right way.
And is it better to just put strtolower in the set_rules parameter? Or is it best to enable the feature?
And if it's separate, how to do it and how do I get the final username data to insert into the database?
Any souls can help me with this?
Thanks in advance.
source
share