Using $_POST to submit? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Using $_POST to submit? (/showthread.php?tid=15675) |
Using $_POST to submit? - El Forum - 02-11-2009 [eluser]Solarpitch[/eluser] Hey Guys, I see in the tutorial video's you can submit a the whole post of a form to the database using this simple line. Code: $this->db->insert('comments', $_POST); This doesnt seem to work for me because it's including the value of the submit button and all... and is trying to put that into the query. INSERT INTO...mysubmit...VALUES..('submit'); I have to use this as a work around which seem a little more than what is needed... Code: $data = array( Is there something I'm missing with this? The one line using the $_POST seems alot easier and less code. Why is it including the value of the submit button also? Using $_POST to submit? - El Forum - 02-11-2009 [eluser]Armchair Samurai[/eluser] [quote author="Solarpitch" date="1234391341"]Why is it including the value of the submit button also?[/quote] That's standard behavior - it has nothing to do with the framework. If it really bothers you that much, just use unset() on the offending element before submitting the $_POST data. Using $_POST to submit? - El Forum - 02-11-2009 [eluser]Solarpitch[/eluser] Ah.... I wasnt aware you could unset it.. but makes sence considering it is an array. Cool.. ill try it later and see how I get on. It's just they dont unset it in the tutorial video and it magically works perfect. Do do do do Using $_POST to submit? - El Forum - 02-11-2009 [eluser]TheFuzzy0ne[/eluser] I'd like to just remind you that inserting the post array into the database before sanitising it is can be very dangerous. Never sacrifice quality for less quantity. Using $_POST to submit? - El Forum - 02-11-2009 [eluser]simshaun[/eluser] I don't want to jump the gun and call you lazy, but don't be lazy. ;-) Just use the long version and play it safe. (Don't forget to sanitize.) Using $_POST to submit? - El Forum - 02-11-2009 [eluser]Solarpitch[/eluser] I agree... thanks lads. I'll use the long method and make sure the data is safely inserted. Cheers. Using $_POST to submit? - El Forum - 02-11-2009 [eluser]Mortred[/eluser] simple. Code: unset($_POST['submit']); and then Code: $this->db->insert('mytable', $_POST); |