HomeFriday, June 23, 2017, 06:58:39
1

Filter Words in PHP - PHP Tutorial

Tuesday, February 10, 15, 13:24:54, 2 Yaers Ago Via wain, Hits: 2020
Filter bad words in PHP, requirement(s): PHP server
Example:
Code:
<?php
if(isset($_POST['submit']))
{
$wordtocheck = $_POST['wordtocheck'];
function wordChecker($string) {
$banedwords = array('badword1','badword2','badword3','badword4','badword5');
for($i=0;$i<=sizeof($banedwords);$i++) {
$string = str_replace($banedwords[$i],"xxxxxx",$string);
}
return $string;
}
if(isset($_POST['submit'])) {
if (strlen($wordtocheck) < 5) die("The field must be at least 5 characters long: Go Back");
if (strlen($wordtocheck) > 100) die("The field cannot contain more than 100 characters: Go Back");
echo wordChecker($wordtocheck);
}
}else{
?>
<form action="index.php" method="post">
<input type="text" name="wordtocheck"><br>
<input type="submit" name="submit" value="Submit"><br>
</form>
<?php
}
?>

jeremy Monday, March 26, 2012, 10:45:43

Thank you for useful piece of code.

Sign In

Sponsor

Related

Email to Friend - PHP Script

This form allows your visitors to suggest your site to a friend. It features an HTML email format and an admin notification email.

Preg_Match - PHP Form Validation

PHP form validation with preg_match

Stack Overflow Clone Script - Ja2BU

Open source question and answer script written in PHP, MySQL and jQuery. Main features are: SEO friendly url's, private message system, rating system, comments system.

Imageline

Draws a line between the two given points.

Preventing multiple form submissions

Preventing multiple form submissions

PHP Mail

Sends an email.

Jquery - Formatting International Phone Numbers

How to format international telephone numbers with jquery

PHP Form Validation

PHP form validation :: PHP tutorial, requirement(s): PHP Server

MySQL Inner Join

MySQL Inner Join - Creating Dynamic Webpages Using PHP and MySQL, Requirement(s): PHP Server, MySQL

PHP Fwrite : fwrite

php write to file - how to write data to a file using the php frwite function
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.