PHP uses AJAX to send passwords in the past, the receiver found that the password is clipped

Source: Internet
Author: User
I didn't use PHP much. Special to this forum to ask.
Now the problem is that the user entered the user name and password, login, if the password simple point, can be passed. But if the password is ab@;&1 this, then found that the server gets the password value is clipped, into ab@; But immediately after the code, the following part is also so operation, incredibly can, really did not find two differences, seeking doubts.

Client part of PHP
function Getfirstu8accid () {var susername = document.getElementById ("user_name"). Value.tolowercase (); var spassword = document.getElementById ("password"). Value;susername = Escape (sUserName), if (susername== "") {return ("");}        var surl = '/server/a.php?t= ' +escape (Date ()) + ' &a= ' +susername+ ' &b= ' +spassword;        var xml = Createxmlhttp (); Xml.open ("GET", Surl,false); Xml.send (); var sloginuser = Xml.responsetext;                                        To deal with ....} The specific call is shown in the following code//Here Call Getfirstu8accid () failed, the specific error is that the server PHP does not get the full password content. Accid = Getfirstu8accid (); Try{var guid = obj. Getclientguid ();} catch (E) {return "error:failed to call Getclientguid,error message:" + e.message;} var surl = '/server/b.php?t= ' +escape (Date ()) + ' &a= ' +user+ ' &b= ' +password+ ' &c= ' +sdomain;var XML =                                        Createxmlhttp (); Xml.open ("GET", Surl,false); Xml.send (null); Here can return normally, because the code in b.php can normally get the password content return xml.responsetext; [/color]a.php b.php in theThe code is probably the following, in fact, basically the same, just a number of parameters in B, more than an analytic. [code=php]
 


Give me the feeling, is the first time after the failure, then do the second time, just with more parameters, on the success. Although the server, a, B, two PHP files, but actually no difference.


Reply to discussion (solution)

The & character appears as a field delimiter in the URL parameter string, and if you have that character in your value, you need to do URL encoding processing (%26)

Moderator really fast ha, but the second time when the submission, it seems that no processing ah.

In addition, URL encoding processing, there is no common code it? I am in English and Chinese three languages, will have influence? PHP is not familiar. I just didn't use it for a long time, do you have any relevant information or small examples?

JS don't have encodeURI, encodeURIComponent method?

The problem is solved. In the first place, there is no escape operation for the password, and the receiving office has unescape processing. And the second place is paired. Thank you for the version prompt.

var surl = '/server/a.php?t= ' +escape (Date ()) + ' &a= ' +susername+ ' &b= ' +spassword;

Change?

var surl = '/server/a.php?t= ' +escape (Date ()) + ' &a= ' +encodeuricomponent (susername) + ' &b= ' +encodeuricomponent (Spassword);

  • 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.