Jump to content

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>.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.