Ad block is installed and active. Please support us by disabling it.
HomeWednesday, April 25, 2018, 08:55:58
1

Filter Words in PHP - PHP Tutorial

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

View content in a zip file with PHP

List all files in a zip archive with PHP

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, Requirement(s): PHP server

PHP explode

Explode — Split a string by string.

Block Visitors From Specific IP Address

Learn How To Restrict Users From Different IP Addresses.

Link Base L.1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

PHP $_GET Function

Get function in PHP

PHP form with image upload

Advanced Contact Form with email and form field validation.It allows your visitors to send you an email directly from your website.Features: Image Upload, HTML Output, Captcha Image.

Creating a Math CAPTCHA with PHP - PHP Tutorial

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

PHP str_replace

str_replace - This function returns a string or an array with all occurrences of search in subject replaced with the given replace value

Preventing multiple form submissions

Preventing multiple form submissions
About Author

wain

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