How to transfer strings to a PHP server via JavaScript

Source: Internet
Author: User
How to transfer strings to a PHP server via JavaScript
There is a page where a specific user can log in and enter the MySQL query command on that page.
Once the PHP server receives the command, it passes the command string directly to MySQL and displays the results on that page.

The contents of the editable control are just passed directly to the server in JavaScript, and the symbols ">" or "<" in the command string are not normal.

After the string with JavaScript encodeuricomponent function after the conversion sent, on the server side and then the PHP html_entity_decode function to convert back, this way, I use most of the commands can be, Just the quotation marks in the command are not normal.

Check to find out, found no way, a string, in the network transmission unexpectedly too much trouble.
Please ask questions!

Share to: more


------Solution--------------------
encodeURIComponent use it to transcode, PHP directly receive it! There's no need to go any further!
------Solution--------------------
Replace Html_entity_decode () with Rawurldecode ();
------Solution--------------------
Htmlspecialchars_decode Try this function

------Solution--------------------
Various transcoding functions try again
------Solution--------------------
It is recommended to use the encapsulated jquery directly to achieve the functional requirements of Ajax
------Solution--------------------
If > ' 5 '
Into the >\ ' 5\ '
Indicates that the MAGIC_QUOTES_GPC switch is open and is automatically escaped
So you need to have
if (GET_MAGIC_QUOTES_GPC ()) {
$_post[' str '] = stripslashes ($_post[' str ');
}
  • 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.