Ladies and gentlemen, I am a beginner. I used the ajaxpost login module to submit data to php. I found that I could normally receive data using gb2312 encoding, and I didn't respond to it using UTF-8 encoding for php. My web pages are all UTF-8 encoded. why? After gb2312 is used, the server can query the database normally. However, after '1' is returned, if and '1' in the js code are not equal, and the result enters the else code, is the encoding format different? Thank you! The js code is as follows: functionloginphp () {xmlhttp. onread... phppost
Ladies and gentlemen, I am a beginner. I used the ajax post login module to submit data to php and found that the data can be normally received using gb2312 encoding, php end encoded with UTF-8 has no response. My web pages are all UTF-8 encoded. why? After gb2312 is used, the server can query the database normally. However, after '1' is returned, if and '1' in the js code are not equal, and the result enters the else code, is the encoding format different? Thank you!
The js code is as follows: function loginphp (){
Xmlhttp. onreadystatechange = function () {if (xmlhttp. readyState = 4 & xmlhttp. status = 200) {msg = xmlhttp. responseText; if (msg = '1') {document. getElementById ("login "). innerHTML = "logon successful! ";} Else if (msg = '2') {document. getElementById (" login "). innerHTML =" incorrect user name or password! ";}Else {document. getElementById (" login "). innerHTML = msg ;}}
}
Xmlhttp. open ("POST", "application/reglog/login. php", true );
// XmlHttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset = utf-8 ");
Xmlhttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset = gb2312 ");
Xmlhttp. send ("email =" + $ ('email '). value + "& pwd =" + $ ('pwd'). value );
}
The php code is as follows:
Include_once "dbconn. php ";
$ SQL = "select * from Basicinfo_user where user_email = '". $ _ POST ['email ']. "'and user_password = '". $ _ POST ['pwd']. "'";
$ Num = $ conne-> getRowsNum ($ SQL );
$ Conne-> close_conn ();
If ($ num = 1 ){
Echo '1 ';
} Else if ($ num = 0 ){
Echo '2 ';
} Else {
Echo $ conne-> msg_error ();
}
?>