Question

There must be a more efficient way to write this code (below) can someone offer a solution that shows multiple Ifs in a more efficient manner?

if (  isset($_POST["submit"])  
   || isset($_POST["submit_x"])
   ) {

    // strip_tags removes tags and then we compare to the original contents
    if (strip_tags($_POST['fld_comments']) !== $_POST['fld_comments']) {

        // Drop post as it had html in it (!==  means Not Identical )
        echo '<h2>No html tags allowed in comments</h2>';
        $blindError = true;  

    } else {

        // run secondary code such to process form

    }
}
Was it helpful?

Solution

Your code is absolutely fine and efficient. I don't see any problems with it, well, you could use a bit less parentheses, but nothing serious.

I mean:

if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top