HTML textarea input doesnt recognize line breaks

前端 未结 2 1240
南旧
南旧 2021-01-29 07:06

I have a really silly problem, but i cannot find a way to solve it, I programming a helpdesk system, with support Tickets I have a form in my website like



        
相关标签:
2条回答
  • 2021-01-29 07:39

    In HTML you use the

    <br>
    

    tag for line breaks. Replace all line breaks (newline characters) with said tag and you should be fine. You can "convert" line breaks (newline characters) to that tag using nl2br() (it really only insert such tags after line breaks (newline characters).

    0 讨论(0)
  • 2021-01-29 07:42

    Escape all special characters before storing it into the database. For instance in MySQL, you can use mysql_real_escape_string. This escapes all special characters while storing in the Database.

    mysql_real_escape_string : http://php.net/manual/en/function.mysql-real-escape-string.php

    Then use nl2br() while displaying back the content from Database.

    nl2br() : http://php.net/manual/en/function.nl2br.php

    0 讨论(0)
提交回复
热议问题