PDA

View Full Version : PHP - words filtering



jjmaster-j
August 11th, 2006, 03:31 PM
Hello all,

The code below is an example of a simple feedback form. However, this code does not allow words filtering words. In other words, anybody can enter any words he/she wants, including bad words and explicit sexual words. Is there a tutorial on how to filter unwanted words from the users?
--------------------------------------------------
<html>
<head>
<title>Listing 9.12 Sending mail from the form in Listing 9.11</title>
</head>
<body>
<?php
print "Thank you, <b>$_POST[name]</b>, for your message!<br><br>\n\n";
print "Your e-mail address is: <b>$_POST[email]</b><br><br>\n\n";
print "Your message was:<br><br>\n\n";
print "$_POST[message] <br><br>";

//start building the mail string
$msg = "Name: $_POST[name]\n";
$msg .= "E-Mail: $_POST[email]\n";
$msg .= "Message: $_POST[message]\n";

//set up the mail
$recipient = "jacques@215d.com";
$subject = "Form Submission Results";
$mailheaders = "From: My Web Site <jacques@215d.com> \n";
$mailheaders .= "Reply-To: $_POST[email]\n\n";

//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>
-----------------------------------------
Thank you
jjmaster-j

Jeff Wheeler
August 11th, 2006, 03:37 PM
Use an array with the case-insensitive string replace method…

http://www.php.net/manual/en/function.str-ireplace.php