Banned words application
<p>Here is my try to create banned words tool but in last step i'm getting error.</p>

<p>1 - Created simple form to input the words to be banned (ban.php)</p>

<pre><code>&lt;form name="form" method="post" action="add.php"&gt;
    &lt;textarea name="bad" id="bad"&gt;&lt;/textarea&gt;
    &lt;input type="submit" name="submit" id="submit" size="12" value="submit"&gt;
&lt;/form&gt;
</code></pre>

<p>2 - Now will post it through db (add.php)</p>

<pre><code>//DB Connection
require_once("config.php");
$bad = $_POST['bad'];
$bad = mysql_real_escape_string($bad);
$bad = nl2br($bad);
$bad = explode("&lt;br /&gt;",$bad);
foreach ($bad as $value)
{
    $sql = "update my_table set words='$value'";
    mysql_query($sql, $conn) or die(mysql_error());
}
echo "Done words added";
</code></pre>

<p>3- Now how to apply it ! check this where i can not do !
i wanna say when <code>$test="shit";</code> then if <code>$test == any of the words added</code> then give banned message and if not then give passed message.</p>

<pre><code>&lt;?php
//DB Connection
require_once("config.php");
//example
$test = "shit";
$qry = "select * from my_table";
$result = mysql_query($qry) or die($qry);
$line = mysql_fetch_array($result);
$words = nl2br($line['words']);
$words = str_replace('&lt;br /&gt;', '', trim($words));
if ($test == $words) 
{
    echo "bannd";
} 
else 
{
    echo "passed";
}
</code></pre>

<p>The problem is i do not know how to compare <code>$test</code> with every single word added since all are stored in db like this </p>

<pre><code>INSERT INTO `my_table` VALUES (1, 'bad\r\nshit\r\ndrugs');
</code></pre>

<p>so any help ~thanks</p>
