[eluser]Bramme[/eluser]
Hi all,
I've got another question: I love how CI works and how you can so easily reduce work. Atm I've got a little guestbook script going on and the insert code looks like this:
Code:
$insert['datum'] = time();
$insert['IP'] = $this->input->ip_address();
foreach($_POST as $key => $value) {
if($key != 'submGb') $insert[$key] = $value;
}
$this->db->insert('gastenboek', $insert);
Now with form validation I make sure the fields are trimmed, not empty and the htmlentities function is also applied. Now as you can see, I have to check first if my $key isn't my submit field, else the db class throws an error. Is there any way of preventing this happens? That would make things even easier!
And also: how safe is this code? I'd think pretty safe as I make sure it's the fields are not empty, and the insert function automatically adds slashes too... But a man can never be too sure, so that's why I'm asking.