Transfer data from form to XML files

BigMek

New member
Joined
Oct 6, 2005
Messages
4
Hi, i creating some security interface where user need to login or register before they can go into the main program, my problem here is whenever user type something in the forms text box which i created, how to make it store in the XML files, can somebody give a guide on this. THX! :)
 
Thanks for your reply, i have try the solutions you provide, but it doesnt work. :(

I would try to explain more details of my situation, im working this security interface on VB.net, i have make 3 Forms for this interface as below;

1) login screen
2) new user registration screen
3) a form of database to store the users details using XML files, such as name and password

but now the problem is whenever new user register it on the new user registration screen, how to make the value in the textbox they type, such as thier name and password would automatically store in the xml file, after clicking a button. (You know, its just like a typical login screen validation process for user whereby new user have to register before they could enter the program and existing user can direct login since their details has already been store in the database file in VB.net form) :rolleyes:
 
Hiya, i have found some articles from MSDN website maybe some use to my project, but im not familiar with C#, can somebody be so good to convert the code for me into VB.net type, heres the code; :rolleyes:

[C#]
<script runat=server>
private void Page_Load(Object Src, EventArgs e)
{

String email = Request.QueryString["UserEmail"];
if( null != email )
UserEmail.Value = email;
}
private void AddUser_Click(Object sender, EventArgs e)
{
if( !Page.IsValid )
{
Msg.Text = "Some required fields are invalid.";
return;
}
DataSet ds = new DataSet();
String userFile = "../users.xml";
FileStream fs = new FileStream(Server.MapPath(userFile),
FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();
string hashedpwd =
FormsAuthentication.HashPasswordForStoringInConfigFile
(UserPass.Value, "SHA1");
DataRow newUser = ds.Tables[0].NewRow();
newUser["UserEmail"] = UserEmail.Value;
newUser["UserPassword"] = hashedpwd;
ds.Tables[0].Rows.Add(newUser);
ds.AcceptChanges();
fs = new FileStream(Server.MapPath(userFile), FileMode.Create,
FileAccess.Write|FileAccess.Read);
StreamWriter writer = new StreamWriter(fs);
ds.WriteXml(writer);
writer.Close();
fs.Close();
Response.Redirect("../Default.aspx");
}
</script>

Thanks in advance ! :p
 
Back
Top