How to retain multiple spaces and wrap text styles when submitting a form, form line feed

Source: Internet
Author: User

How to retain multiple spaces and wrap text styles when submitting a form, form line feed

The requirement is that the user can block sensitive words when submitting a form. Sensitive words are the same as ciku.txt on the server end. sensitive words are connected by "|", for example, "g | c | a". When a form is submitted, sensitive words are replaced,More importantly, you must keep multiple spaces and line breaks entered by users in the form text field and output them as they are.The php code is as follows:

1 <? Php 2 header ("Content-type: text/html; charset = UTF-8"); 3 if ($ _ POST) {4 $ pattern = array (5 '//', // space 6 '//' At the half-width corner, // space 7 '/\ r \ n/' At the full-width corner, // line break under window 8'/\ n /', // line break 9 in Linux and Unix); 10 $ replace = array ('& nbsp;', '& nbsp;', '<br/> '); 11 $ message = preg_replace ($ pattern, $ replace, $ _ POST ['message']); 12 $cikustr1_file_get_contents('ciku.txt '); 13 $ cikuArr = explode (' | ', $ cikuStr); 14 $ liuyan = str_replace ($ cikuArr, "**", $ Message); 15 echo 'your message is: <br> '. $ liuyan; 16} 17?>
1 <! -- This is the form page code -->
2 <body> 3 <form name = "message_board" id = "message_board" method = "post" action = "timu. php "> 4 <textarea name =" message "id =" message "cols =" 50 "rows =" 10 ">
5 "http://www.cnblogs.com/phpdream/" --- Yong zhiquan 6 </textarea> <br/> 7 <input type = "submit" value = "submit message" id = "submitMessage" onclick =/> 8 </form> 9 </body>

The effect is as follows:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.