Php $_POST method to get textarea value

前端 未结 8 1475
一整个雨季
一整个雨季 2021-02-01 08:45

I am using php to get textarea value using post method but getting a weird result with that let me show you my code

8条回答
  •  甜味超标
    2021-02-01 09:43

    Use htmlspecialchars():

    echo htmlspecialchars($_POST['contact_list']);
    

    You can even improve your form processing by stripping all tags with strip_tags() and remove all white spaces with trim():

    function processText($text) {
        $text = strip_tags($text);
        $text = trim($text);
        $text = htmlspecialchars($text);
        return $text;
    }
    
    echo processText($_POST['contact_list']);
    

提交回复
热议问题