| | |
filter some words while submitting form
![]() |
•
•
Join Date: Sep 2008
Posts: 159
Reputation:
Solved Threads: 0
Hai,
I had developed a self forum ( not third party ) for my web site. Working fine... But now I need to filter some words while submitting the form. Ie If I need to filter the word "duck" in forum then if an user type "duck" in any of the text box/area then I need to change that into "d**k" on form submitting.
Please give me a little advice to solve this problem...
Thanks in advance
Rajeesh
I had developed a self forum ( not third party ) for my web site. Working fine... But now I need to filter some words while submitting the form. Ie If I need to filter the word "duck" in forum then if an user type "duck" in any of the text box/area then I need to change that into "d**k" on form submitting.
Please give me a little advice to solve this problem...
Thanks in advance
Rajeesh
0
#2 Nov 10th, 2009
Hey.
Consider this:
That should work, right?
Consider this:
php Syntax (Toggle Plain Text)
<?php /** * Obfuscates a word by replacing all but the first and the last letters with * * @param string $word The unscrabled word. * @return string */ function obfuscateWord($word) { $first = $word[0]; $last = $word[strlen($word)-1]; $middle = ""; for($i = 0; $i < strlen($word)-2; $i++) { $middle .= "*"; } return $first . $middle . $last; } // A list of banned words $wordList = array('duck', 'fick'); // Compile the regular expression that searches for the words in the list. $regexp = '/(' . implode('|', $wordList) . ')/ie'; // The "callback" for the regular exrepssion matches. // This calls the obfuscateWord function, passing the matches word and replacing it // with the scrambled word. $replace = 'obfuscateWord("$1");'; // Example text to use $text = "There is a duck on the fick!"; // Do the actual replace. $text = preg_replace($regexp, $replace, $text); echo $text; ?>
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
And use [code] tags!
![]() |
Similar Threads
- Question on submitting form info. to an email. (JavaScript / DHTML / AJAX)
- how can i send my autoresponse program while submitting the form in Aweber.com (HTML and CSS)
- FILTER QUERY results on a FORM? (Visual Basic 4 / 5 / 6)
- How Do We Make A Form Without Post Or Get (PHP)
- Problems in Dynaform (Form Mail) URGENT HELP (PHP)
- Automatically writing webpages by submitting a form... (PHP)
Other Threads in the PHP Forum
- Previous Thread: Show Data from SQL Database Using PHP
- Next Thread: E-Leave system
Views: 258 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache array arrays beginner binary box buttons cakephp cart check checkbox class cms code cookies database date delete directory display download dropdown drupal dynamic echo email error file files form forms function functions header href htaccess html image images include insert ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql order output parse password paypal php problem query radio regex remote results script search security select server session soap sort sorting source sql string system table tutorial update updates upload url user validation validator variable video web website wordpress xml





