ASP.NET C# Help me fix member sign up code

Hi, I wrote the following code.
I get no compiler errors, but it doesn't work either.
it is supposed to:
Check form values against records in an .xml db file and if not found,
add the values as a new record, and then send a email to the address submitted by the form.
After which it will set some session variables and redirect.

private void btnSend_Click(object sender, Systemail.EventArgs e){
string bodymessage;
bodymessage="All the body stuff here;

  string name;
  string email;
  email=email.Text;
  name=name.Text;
 
  XmlDocument doc = new XmlDocument();
  doc.Load(Server.MapPath("xmlfile.xml") );
  XmlElemailent root = doc.DocumentElemailent;
  XmlNodeList nodes = root.SelectNodes("/memailber");
 // You can filter elements here using XPath
 
  foreach (XmlNode node in nodes){
 
    if (node["email"].InnerText == email){
     lblStatus.Text = "Member already exists";
    }else{
      //user not found so insert the data
      node["name"].InnerText =name ;
      node["email"].InnerText= email;
    //send email
      MailMessage msg = new MailMessage();
      msg.To = email;
      msg.From = "from@address.com";
      msg.Subject = "something";
      msg.Body = bodymessage;
      SmtpMail.Send(msg);
      //set session vars

      Session["thissession"] = name;
      Session["thissessionvar"] = 1;
      //redirect
      Server.Transfer("page.aspx");
    }

  }


}

Help!
Thanks in advance
dotinfinitiAsked:
Who is Participating?
 
dotinfinitiConnect With a Mentor Author Commented:
Thanks guru, but I fixed it myself with the following:

First I changed this line \/
        XmlNodeList nodes = root.SelectNodes("/parent");
With this line \/
        XmlNodeList nodes = root.SelectNodes("/root/parent");

AND
This area \/
      //user not found so insert the data
      node["name"].InnerText =name ;
      node["email"].InnerText= email;

was replaced with this \/
        XPathNavigator xn = doc.CreateNavigator();
        xn.MoveToFirstChild();
        xn.AppendChild("<parent><child>"+var+"</child><child>"+var+"</child><child>"+var+"</child></parent>");
        doc.Save("file.xml");

It helps if you append the information and  save the document  :)
0
 
dotinfinitiAuthor Commented:
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Xml" %>
0
 
guru_samiCommented:
did you set breakpoints in your code to see what is executed and what is not?
Check this article that authenticates user agains xml:
http://www.dotnetfunda.com/articles/article141.aspx
0
 
dotinfinitiAuthor Commented:
The above code works, except that it doesn't insert the data into the xml file.
The check for duplicates and  send mal work fine
0
All Courses

From novice to tech pro — start learning today.