I'm trying to use an XML file like below for users to login to my
website. I have some code started below, but I'm sure there's a better
way. "(email = txtEmailAddress And password = txtPassword)" does not
compile.

<?xml version="1.0" standalone="yes"?>
<members>
  <member>
    <firstName>Ralph</firstName>
    <lastName>Ward</lastName>
    <emailAddress>[email protected]</emailAddress>
    <password>1920</password>
  </member>
</members>


 Private Sub btnLogin_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnLogin.Click

        Dim ds As DataSet = New DataSet
        ds.ReadXml(MapPath("members.xml"))
        Dim email As String = ""
        Dim password As String = ""

        If ds.Tables(0).Rows.Count > 0 Then
            email = ds.Tables(0).Rows(0)("EmailAddress").ToString()
            password = ds.Tables(0).Rows(0)("Password").ToString()
        End If

        If (email = txtEmailAddress And password = txtPassword) Then
            lblLoginFailure.Visible = True
            lblLoginFailure.Text = "Welcome to Our Site."
        Else
            lblLoginFailure.Visible = True
            lblLoginFailure.Text = "Email Address and/or Password are
incorrect. Please try again."
        End If
End Sub

Reply via email to