skip to Main Content

I want to restrict the user if they are trying to submit comment like this "hjshssjdh" how can i restrict them

I have try many ways but still not getting the solution suggest me a solution how can i restrict the user that server is not accept this type of message write a meaning full comment

2

Answers


  1. I think you can use google reCAPTCHA as a strong solution.

    check its documents here.

    Let me know if this is not what you need.

    Login or Signup to reply.
  2. You can use pspell_check() funtion in PHP 8.1.0

    <?php
    $pspell = pspell_new("en");
    
    if (pspell_check($pspell, "testt")) {
        echo "This is a valid spelling";
    } else {
        echo "Sorry, wrong spelling";
    }
    ?>
    

    Detail page in here: https://www.php.net/manual/en/function.pspell-check.php

    Also for full comment function could be like:

    <?
    function SpellCheck($comment) {
        $pspell_link = pspell_new("en");
        preg_match_all("/[A-Z']{1,16}/i", $comment, $words);
        for ($i = 0; $i < count($words[0]); $i++) {
            if (!pspell_check($pspell_link, $words[0][$i])) {
                $comment = str_replace($words[0][$i], "<font color="#FF0000">" . $words[0][$i] . "</font>", $comment);       
            }
        }
        return $comment;
    }
    ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search