[eluser]Keloo[/eluser]
Hi,
I want to write a function in CI that checks if a certain comment exists in the db, and if it does to display a message something like "This comment was flagged as spam ".
I've done it, but if I change a letter in that comment, it will be posted.
So my question is, how can I make it more secure then this, to prevent spam comments ?
Here is the current code :
Controller
Code:
function comment_check($str)
{
$this->load->model('users_model');
if($this->users_model->comment_check($str) > 0)
{
$this->form_validation->set_message('comment_check', 'This comment was flagged as spam !');
return FALSE;
}
else
{
return TRUE;
}
}
Model
Code:
function comment_check($comment)
{
$this->db->where('body',$comment);
return $this->db->get('comments')->num_rows();
}