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 ');
}