Subject: help xml login
Posted By: daddycool2k Post Date: 11/12/2003 8:33:17 PM
Author:  craig
Date:  11/12/2003 8:28:28 PM
Subject:  need help searching for two values
Message:  i am tryin 2 create a login page where the user enters a username and a password and an asp script checks these values and allows them 2 login. I have successfully created the script where it checks the username value, but i have not got a clue in order 2 amend the script to check for the password value
my xml tree is
<records>
       <details>
               <username></username>
               <password></password>
      <details>
</records>
the asp script so far is
<%@ Language="VBScript" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>

<body>
<%
Dim xmlDocument, path, nodes
set xmlDocument = CreateObject("MSXML2.FreeThreadedDOMDocument")
xmlDocument.async = "false"
xmlDocument.load(Server.MapPath("/speirsy/db/user.xml"))
xmlDocument.setProperty "SelectionLanguage", "XPath"

path = "/records/details[username='" & Request.Form("userQuery") & "']"
set nodes = xmlDocument.selectNodes(path)

If nodes.length = 0 Then
   Response.write("No Match")
End If

For Each Node In nodes
   For Each Node1 In Node.childNodes
    If Node1.nodeName = "username" Then
        If Node1.text = Request.Form("userQuery") Then
Response.Write(" Welcome " & Request.Form("userQuery"))
        End If
      End If
   Next
Next
%>




any help would be much appreciated


thanks



Reply By: planoie Reply Date: 11/12/2003 11:20:17 PM
Modify your XPath query to include criteria for the password:

path = "/records/details[username='" & Request.Form("userQuery") & "' and password='" & Request.Form("passwordQuery") & "' ]"

Peter
------------------------------------------------------
Work smarter, not harder.
Reply By: daddycool2k Reply Date: 11/13/2003 5:04:27 AM
thanks for the reply, but how would i check the nodes for username and password?
ma code so far is
For Each Node In nodes
   For Each Node1 In Node.childNodes
    If Node1.nodeName = "username" Then
         If Node1.text = Request.Form("userQuery") Then
Response.Write(" Welcome " & Request.Form("userQuery"))
         End If
      End If
   Next
Next


Go to topic 6368

Return to index page 1006
Return to index page 1005
Return to index page 1004
Return to index page 1003
Return to index page 1002
Return to index page 1001
Return to index page 1000
Return to index page 999
Return to index page 998
Return to index page 997