Welcome Guest, Not a member yet? Register   Sign In
How can I prevent spam comments ?
#1

[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();
  }
#2

[eluser]adityamenon[/eluser]
What's wrong with CAPTCHA? Did you try using Recaptcha? There's even a handy library in CI that integrates ReCaptcha... I use it extensively with great effect.




Theme © iAndrew 2016 - Forum software by © MyBB