Php $_POST method to get textarea value

前端 未结 8 1290
一整个雨季
一整个雨季 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:42

    Try to use different id and name parameters, currently you have same here. Please visit the link below for the same, this might be help you :

    Issue using $_POST with a textarea

    0 讨论(0)
  • 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']);
    
    0 讨论(0)
提交回复
热议问题