Questions about PHP beginners! Thank you!

Source: Internet
Author: User
PHP beginner question !! Thank you !! I learned about an open-source project on the internet. the only place for registration and verification is a bit problematic. I don't know what went wrong. JS calls php file verification but does not know why it returns 0 and does not know why there is an error. JS code: functionchkname (form) {if (form. na PHP beginner question !! Thank you !!
I learned about an open-source project on the internet. the only place for registration and verification is a bit problematic. I don't know what went wrong.
JS calls PHP file verification but does not know why it returns 0 and does not know why there is an error.

JS code:
Function chkname (form ){
If (form. name. value = "")
{
Name1.innerHTML = "enter the user name! ";
}
Else
{
Var user = form. name. value;

Var url = "chkname. php? User = "+ user;

XmlHttp. open ("GET", url, true );
XmlHttp. onreadystatechange = function ()
{

If (xmlHttp. readyState = 4)
{
Var msg = xmlHttp. responseText;
If (msg = '2 '){
Name1.innerHTML = "the user name is occupied! ";
Return false;
} Else if (msg = '1 '){
Name1.innerHTML = "Congratulations, you can register! ";
Form. c_name.value = "yes ";

} Else {
Name1.innerHTML = "" + msg + "";
}
}
}
XmlHttp. send (null );
}
}

PHP code: Session_start ();
Include_once "conn/conn. php ";
$ Reback = '0 ';
$ SQL = "select * from tb_user where name = '". $ _ GET ['user']. "'";
$ Rst = $ conn-> Execute ($ SQL) or die ('execute error ');
If ($ rst-> RecordCount () = 0)
{

$ Reback = '1 ';
}
Else
{
$ Reback = '2 ';
}
Echo $ reback;
?>


------ Solution --------------------
Discussion
$ Rst = $ conn-> Execute ($ SQL) or die ('execute error ');
If ($ rst-> RecordCount () = 0)

------ Solution --------------------
"Php ajax registration Source Code"
Http://www.baidu.com? Bs = php + ajax + % D7 % A2 % B2 % E1 % B5 % C7 % C2 % BD % CD % CB % B3 % F6 + % D4 % B4 % C2 % EB & f = 8 & rsv_bp = 1 & wd = php + ajax + % D7 % A2 % B2 % E1 + % D4 % B4 % C2 % EB & inputT = 190

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.