Ad block is installed and active. Please support us by disabling it.
HomeMonday, January 22, 2018, 18:20:02
1

Filter Words in PHP - PHP Tutorial

Tuesday, February 10, 15, 13:24:54, 3 Yaers Ago Via wain, Hits: 3262
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

Images In Textarea - CSS

Tutorial Images in Textarea

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.

Create dynamic Web Pages with PHP & MySQL

Create dynamic Web Pages with PHP & MySQL, Requirement(s): PHP Server, MySQL

PHP Form Action Self Submit

PHP form action self submit tutorial, requirement(s): PHP server

Creating a CAPTCHA with PHP :: PHP Tutorial

Captcha Image, This tutorial will show you how to create a form with Captcha.

PHP getdate

Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given.

MySQL Basic Functions

MySQL Basic Functions - select, delete, update..

PHP Mail

Sends an email.

RSS, MySQL & Smarty

Smarty > Publishing MySQL Data in RSS 2.0

Site Recommendation

This script will allow your visitors to recommend your site to their friends.
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.