HomeMonday, July 24, 2017, 22:37:18
1

Filter Words in PHP - PHP Tutorial

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

MySQL to RSS

Publishing MySQL data in RSS

PHP imagecreate

imagecreate() returns an image identifier representing a blank image of specified size.

Creating a CAPTCHA with PHP :: PHP Tutorial

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

PHP Cookies and Sessions Tutorial

PHP Cookies and Sessions Tutorials

Show / Hide Div with CSS

CSS Display and Visibility:The visibility property specifies whether or not an element is visible.

Link Base 1.1. - Free PHP Link Index Script

Manage your links using a MySQL database. Features easy install, user submission, and an admin panel to add, edit and remove categories and links.

PHP Cookies - setcookie

Defines a cookie to be sent along with the rest of the HTTP headers.

Upload and Resize an Image with PHP

Tutorial - How to upload and resize image with PHP

Smarty - Create dynamic Web Pages with PHP & MySQL

Creating Dynamic Web Pages Using Smarty and MySQL - Requirement(s): PHP Server, MySQL

Bookmark Script

Allow your users to easily bookmark your site, by clicking on a link on the page.
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.