Processing of javascript-post and displaying special characters

Source: Internet
Author: User
{Code...} displays the result as follows: OK. The problem arises. When I enter a general character in the input box, save it to the database, and finally retrieve it in the input box, there is no problem. When a special character such as & #039; & quot; & amp; lt; & amp; gt; is entered, although it is included in the php retrieval and retrieval process...
Data "/>

The displayed result is as follows:

Okay, the problem is. When I enter a general character in the input box, save it to the database, and finally retrieve it in the input box, it is okay.

When the input example is '"<> this special character, although \ and \ are added during php acquisition and removal \, however, these characters will still be displayed in the input, which will lead to disorder in the html format.

In my current practice, replace the English and "with the Chinese" and ", and then replace them with escape characters when receiving post, for example:

<Less than or show Mark> greater than or show Mark & can be used to display other special characters "" quotation marks

But it is never the best solution. Could you tell me:

1. How can I solve the problem?

2. What should I do in an editor such as kingeditor and fck?

.

Reply content:
Data "/>

The displayed result is as follows:

Okay, the problem is. When I enter a general character in the input box, save it to the database, and finally retrieve it in the input box, it is okay.

When the input example is '"<> this special character, although \ and \ are added during php acquisition and removal \, however, these characters will still be displayed in the input, which will lead to disorder in the html format.

In my current practice, replace the English and "with the Chinese" and ", and then replace them with escape characters when receiving post, for example:

<Less than or show Mark> greater than or show Mark & can be used to display other special characters "" quotation marks

But it is never the best solution. Could you tell me:

1. How can I solve the problem?

2. What should I do in an editor such as kingeditor and fck?

.

Escape when output
htmlspecialchars()

Obviously, you should not escape it like this.

You should convert double quotation marks"Such characters.

Close the post by yourself:
1. Use addslashes () to add a slash to a special character before writing SQL.
2. After SQL is extracted, use tripslashes () to slash special characters
3. When html is output, use htmspecialchars () to convert special characters into html Escape characters.

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.