CodeIgniter Forums
Nice way of getting field values? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Nice way of getting field values? (/showthread.php?tid=22726)



Nice way of getting field values? - El Forum - 09-18-2009

[eluser]überfuzz[/eluser]
Is there a fancy pancy way of getting field values from a <form etc.. > in a viewer lets say form.php to a controller email.php. Or is it the old fashion way. I can't find any thing in the user_guide. Is it because there isn't anything or did I mess up the search?

Code:
$message = $_POST['firstname']. " says hello frendo!";
$message .= "You can email me on ".$_POST['email'].".";
$this->email->message($message);



Nice way of getting field values? - El Forum - 09-18-2009

[eluser]daparky[/eluser]
If you are going to be inserting data i just do something like this:-

Code:
$values = $_POST;

$this->db->insert('mytable', $values);

But for email, i think you have to do it the way your doing it.


Nice way of getting field values? - El Forum - 09-19-2009

[eluser]überfuzz[/eluser]
I guess this is the CI-way.
Code:
$this->input->post('name');



Nice way of getting field values? - El Forum - 09-19-2009

[eluser]timaksu[/eluser]
you guess correct.


Nice way of getting field values? - El Forum - 09-19-2009

[eluser]wabu[/eluser]
If you name your form fields like "animal[name]" then "$this->input->post('animal')" gets you your complete animal.

Combine it with something like the following for bonus points. Wink

http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/