In my controller i have a view for registering new members.
Instead of making a whole new function for that such as,
public function show_registration(){
$this->load->view('registration');
}
public function validate_registration(){
}
Instead of doing the one above where i make a function to show the view then a new one to receive the data from the view, i made it like this.
public function registration(){
if(array_key_exists('submit',$_POST)){
/////if exist process the data here
}else
$this->load->view('registration');
}
The above if statement, checks if ever there was data submitted to the function if not then it would show the view else it will process the data.
It seems like more of an ideal way right? then i thought, what if this could cause problems?
Is there any chance or possibility this might ruin my project? I am starting right now, and i just want insights whether i should pursue my current way or i should just create a separate one for showing the view.
**EDIT: I just realized, this does not necessarily check all submitted data, but only data submitted by the button of the name 'submit', so as long as i keep the name of the submit button for every form unique as possible then i should be fine.
sample: form for registration, button name should be registration.**
inputclass since it has some useful filters and check out validation class for forms as well. ellislab.com/codeigniter/user-guide/libraries/input.html ; ellislab.com/codeigniter/user-guide/libraries/…