Argo
Argo

Reputation: 103

Create a Blacklist filter in a form to avoid some words

I need to create a filter to avoid some websites to be submitted to my database. I want to do this to protect the content of my website against spammers.

I have a regular form input text that is used to send a URL, I need some help to create a background action (in php maybe) that will check if this URL, that the user is trying to send, have some blacklisted words.

Upvotes: 1

Views: 883

Answers (2)

Mike Brant
Mike Brant

Reputation: 71422

You probably want to store a list of regular expressions (either in a database, or hard-coded in a file - whichever you find more convenient to work with and flexible long-term).

Then just filter the input against the the regular expressions using preg_filter or similar.

Upvotes: 1

Erik
Erik

Reputation: 2264

You probably want to look into preg_match

http://php.net/manual/en/function.preg-match.php

Upvotes: 0

Related Questions