JavaScript reads XM child nodes without a refresh example (javascript,xml,php)

Source: Internet
Author: User

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)

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.