how to get data from the form |
[eluser]pshah.mumbai[/eluser]
I have setup the validation and everything and I need to enter the data into the database. how do i get the data from the FORM fields ? $_POST/$_GET ? What is the name of the array that has the data from the form field eg : post['username'] ??
[eluser]ejangi[/eluser]
Check out the input/security class: Code: $username = $this->input->post('username');
[eluser]coolfactor[/eluser]
You can *always* use standard PHP within CodeIgniter, but ucantblamem pointed you to the "CodeIgniter way" of doing it, which offers some protection against values that might not exist in the form data.
[eluser]Colin Williams[/eluser]
The best way, IMO, is to use the Validation class. The Validation class is namespaced in such a way that it allows for all your defined fields to become properties of the validation object ($CI->validation). The bonus here is that these properties are "cleaned" in the validation process if you use available or custom validation rules. Take this bit of a controller for example: Code: function capture(){ |
Welcome Guest, Not a member yet? Register Sign In |