Hi I have a website that has an online form. Recently, people have been using profanity and extreme swearing in malicious messages to me. Is there an easy way to block certain words? any help is appreciated as always Thanks! - Derek
create an array or a table that will hold all the malicious contents or words. what ive done is before they can submit a post i will search the contents for the restricted words... well thats what im going to do..
This might help $form = 'hello world i am submitting to a website'; $badWords = array('these', 'are', 'your', 'swear', 'words'); foreach ($badWords as $word) { if (strpos($form, $word) !== FALSE) { $swearing = TRUE; break; } } if (isset($swearing)) { echo 'There were swear words'; } else { echo 'There were no swear words'; } PHP: Not perfect but it should get you started
I think this would be better. $form = 'hello world i am submitting to a website'; $badWords = array('these', 'are', 'your', 'swear', 'words'); $form = str_replace($badWords, "[censored]", $form); Code (php): Yes you can use arrays in str_replace()