How to test if a HTML body contains empty tags

后端 未结 2 1586
轮回少年
轮回少年 2021-01-28 02:25

I am using a text editor on certain form fields, TinyMCE. it works ok.

However the TinyMCE editor returns a HTML body tag for each field in the form. T

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 03:05

    its not a very ellegant solution but it works. i simply remove the tags from the document using the strip_tag(), then test if the variable is empty. If its not empty i submit the post variable.

    if (isset($_POST['description']))
                    {
                        $preValidated = dsf_db_prepare_input($_POST['description']);
                        $testValue  = trim(strip_tags($preValidated));
    
                        if(!strlen($testValue) >= 1)
                        {
                            $description ='';
                         }
                         else
                         {
                            $description ="$preValidated";
                         }     
                    }
    

提交回复
热议问题