Jump to content

[SOLVED] Important question about PHP.


pojr

Recommended Posts

For if statements, well lets say my post content is under $post, and I don't want this content to have any curse words. If I were to do:

 

if ( $post == gris ) {
          echo "<h1>Error!</h1> Gris is a naughty word. I cannot let you say that on this site!"; 

 

It would vary. If I posted just gris on the post line, I would get the error message, but posted I like gris, the post would go through. I know the if == is sharp, so is there a way for $post to register one word in the post? Thanks a bunch in return.

Link to comment
https://forums.phpfreaks.com/topic/112675-solved-important-question-about-php/
Share on other sites

Do you mean something like this...

 

 

<?php

$var = "This is a string. Strings are bad, so is the word is.";

if (!(strpos($var, "string") === false))
{
  echo "The word 'string' is a naughty word!<br />";
}

?>

 

This way will check if the word is found anywhere in the string. You could also use str_replace() to remove any occurences of bad words and replace them with something else (*'s for instance).

Sounds good, but this script is not working.

 

<?php

if (!(strpos($pst, "<b>" ) === true)) {

        if (!(strpos($pst, "</b>" ) === false)) {
$htmlallowance = "negative";
}

}

?>

 

The post in my forums still go through then I don't add a </b> when posting <b>.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.