CodeIgniter Forums
Trouble With Form Helper and Databases - 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: Trouble With Form Helper and Databases (/showthread.php?tid=13121)



Trouble With Form Helper and Databases - El Forum - 11-11-2008

[eluser]Bl4cKWid0w[/eluser]
I have a form that submits new information into the database. The only problem is that it's trying to submit the value of the submit input button into the database. Since the name of the button is 'confirm', this causes my script to work incorrectly since there is no such table field. I also tried using form_submit(), but that didn't seem to work either. Anyone have any ideas?


Trouble With Form Helper and Databases - El Forum - 11-11-2008

[eluser]cideveloper[/eluser]
Code snippet would help us help you. Is your controller method iterating through all post fields and using the name value as the field value in the database?


Trouble With Form Helper and Databases - El Forum - 11-12-2008

[eluser]Developer13[/eluser]
Don't pass the entire $_POST array to the database.


Trouble With Form Helper and Databases - El Forum - 11-12-2008

[eluser]julgus[/eluser]
You can clean the $_POST array using unset($_POST[element]) and end up with a structure which you can use in the function update_string

Regards


Trouble With Form Helper and Databases - El Forum - 11-12-2008

[eluser]lmv4321[/eluser]
Passing the entire $_POST array to the database is a bad idea as it makes you vulnerable to XSS attacks.