Character filtering project_php tutorial

Source: Internet
Author: User
Character filtering program. According to the customer's requirements, they can manually set and filter unnecessary keywords in the background, so they will write the following code, character filtering program! DOCTYPEhtmlPUBLIC-based on customer requirements, they can manually set and filter unnecessary keywords in the background, so they can write the following code: character filtering program




Untitled Document








If ($ _ POST ){
$ Words = isset ($ _ POST ['fiter _ word'])? $ _ POST ['fiter _ word']: '';
$ SQL = "Update gx_filter set filter_words = '$ word' where id = 1 ";
Mysql_query ($ SQL) or die (mysql_error ());
Echo "script" alert ('set successfully'); location = 'filter. php'; script ";
}
?>
This is on the character filtering page. let's take a look at how to determine and filter characters that are not allowed by our customers.

Function filter_words ($ str ){
$ SQL = "Select * from gx_filter where id = 1 limit 1 ";
$ Result = mysql_query ($ SQL );
$ Rs = mysql_fetch_array ($ result );
$ Array = explode ('|', $ rs ['filter _ word']);
If (is_array ($ array )){
$ Array_length = sizeof ($ array );
For ($ I = 0; $ I <$ array_length; $ I ++ ){
$ Str = @ str_replace ($ array [$ I], '', $ str );
}
}
Return $ str;
}
Read the characters to be filtered from the database, and then process them as above.

Application: for original site reprinted, please indicate www.111cn.cn/phper/php.html

Success! DOCTYPE html PUBLIC -//...

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.