The following JavaScript function is used to make no refresh to determine whether the user name and password are correct
<script language= "JavaScript" >
function login_sussess () {
var flag = false;
var user,psw;
user = Form1.user.value;
PSW =form1.psw.value;
Coder = Form1.coder.value;
form1.submit2.disabled = "false";
document.getElementById ("Check_result_title"). InnerHTML = "landing ...";
var oxmldoc = new ActiveXObject (' MSXML ');//Creating an XML Document Object
sURL = "js/login_go.php?user=" +user+ "&psw=" +psw+ "&coder=" +coder//load data page
Oxmldoc.url = sURL; Load data to object URL
var oroot = oxmldoc.root;//Read root node
Oitem = Oroot.children.item (0);
If you also want to read Oitem's child nodes, you should oItem.children.tiem (i), and so on
if (Oitem.text = = ' 1 ') {
document.getElementById ("Check_result_title"). InnerHTML = "username or password is incorrect";
form1.submit.disabled = "true";
}else if (Oitem.text = = ' 2 ') {
document.getElementById ("Check_result_title"). InnerHTML = "Incorrect verification code";
form1.submit.disabled = "true";
}else if (Oitem.text = = ' 3 ') {
document.getElementById ("Check_result_title"). InnerHTML = "landed successfully,";
Location.href = "index.php";
}
}
</script>
The following section is the source code of login_go.php:
<?php
Require_once (".. /class/_conn.php ");
if (Isset ($_request["user"]) &&$_request["user"]) $user = Trim ($_request["user"]);
if (Isset ($_request["PSW") &&$_request["PSW"]) $user = MD5 (Trim ($_request["PSW"));
if (Isset ($_request["coder"]) &&$_request["coder"]) $coder = Trim ($_request["coder"]);
$flag = ' 1 ';
Print ("<?xml version= ' 1.0 ' encoding= ' gb2312 '?>");
Print ("<plan>");
$result = $connection->my_query ("SELECT * from ' Members ' where username = ' $user ' and password = ' $PSW '", $connection-&G T;conn);
if ($row = $connection->my_array ($result)) {
if ($_session["code"]! = $coder) {
$flag = ' 2 ';//Incorrect verification code
}else{
$flag = ' 3 ';//Login Successful
}
}
$connection->my_mysql_close ($result);
echo "<result> $flag </result>";
Echo ' </plan> ';
?>
The XML content for this section of PHP output is:
<?xml version= "1.0" encoding= "gb2312"?>
<plan>
<result>1</result>
</plan>
JavaScript reads XM child nodes without a refresh example (javascript,xml,php)