Ad block is installed and active. Please support us by disabling it.
HomeMonday, November 20, 2017, 09:09:41
1

Filter Words in PHP - PHP Tutorial

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

Getimagesize

Getimagesize function will determine the size of any given image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag and the correspondant HTTP content type.

PHP File Create

Create and write data to a file using the php frwite function.

Smarty Paginate Example - Smarty Pagination with PHP

Smarty Paginate Example, Smarty Pagination with PHP. SmartyPaginate: a class/plugin for data set pagination within the Smarty template environment

PHP Mail

Sends an email.

Send This Link PHP Script

A popup form which allows your visitors to send a referral link from your site. It features admin notification and HTML output.

Creating a basic bad word filter in PHP

This tutorial will show you how to create a basic bad word filter in PHP

Sitemap

phpForm.net Website Sitemap

HTML Button Generator

This script will allow your visitors to create HTML Buttons online. To use the "html button generator" script completely free , the "powered by" link at the bottom of the pages must stay intact.

Creating a CAPTCHA with PHP with imagecreate

This tutorial will show you how to create a form with Captcha, Requirement(s): PHP Server, GD Graphics Library

Contact Us 2.0. :: PHP Form

Version 2.0. - A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.
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.