PHP Novice Related issues! Ask your heroes to show you the maze!

Source: Internet
Author: User
PHP Novice Problem!! Ask your heroes to guide the maze!!
I got an open source project on the Internet. The only place where the registration verifies the username is a problem.
JS Call PHP file verification but do not know why the return of a 0 do not know there is a mistake.

JS Code:
function Chkname (form) {
if (form.name.value== "")
{
Name1.innerhtml= "Please enter your 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= "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--------------------
discuss
$rst = $conn->execute ($sql) or Die (' Execute error ');
if ($rst->recordcount () = = 0)

------Solution--------------------
"PHP Ajax registered source code"
http://www.baidu.com/s?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
  • Related Article

    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.