T
thomas
This should be pretty simple for you guys. I've been trying to append values
to my XML file but I can't get it to work correctly.
index.html passes the values of a form to the new_user.asp file and I want
it to write my members.xml file.
Once the xml file has been written and saved, I coded the ASP file to
redirect to google, just to see if its working, which it does but the data
has not been written to the XML file.
Any ideas where I'm going wrong.
index.html
=======
<html>
<body>
<form action="new_user.asp" method="post" name="new_user_form">
<table>
<tr>
<td>
<table>
<tr>
<td>Username:</td>
<td><input name="Username" type="text"></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input name="Email" type="text"></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="Password" type="password"></td>
</tr>
</table>
<p><input type="submit" name="submit" value="submit"></p>
</td>
</tr>
</table>
</form>
</body>
</html>
new_user.asp
=========
<%@ Language=JScript%>
<%
var username = Request.Form("Username")
var email = Request.Form("Email")
var password = Request.Form("Password")
var xmlDoc=Server.CreateObject("MICROSOFT.FreeThreadedXMLDOM");
xmlDoc.async="false";
xmlDoc.load(Server.MapPath("/members.xml"));
var nodeList = xmlDoc.getElementsByTagName("members");
if(nodeList.length > 0){
var parentNode = nodeList(0);
var memberNode = xmlDoc.createElement("member");
var usernameNode = xmlDoc.createElement("username");
var emailNode = xmlDoc.createElement("email");
var passwordNode = xmlDoc.createElement("password");
usernameNode.text = username;
emailNode.text = email;
passwordNode.text = password;
parentNode.appendChild(memberNode);
memberNode.appendChild(usernameNode);
memberNode.appendChild(emailNode);
memberNode.appendChild(passwordNode);
xmlDoc.save(Server.MapPath("/members.xml"));
}
Response.Redirect("http://www.google.co.uk")
%>
members.xml
=========
<members>
<member>
<username>thomas</username>
<email>[email protected]</email>
<password>123456</password>
</member>
</members>
to my XML file but I can't get it to work correctly.
index.html passes the values of a form to the new_user.asp file and I want
it to write my members.xml file.
Once the xml file has been written and saved, I coded the ASP file to
redirect to google, just to see if its working, which it does but the data
has not been written to the XML file.
Any ideas where I'm going wrong.
index.html
=======
<html>
<body>
<form action="new_user.asp" method="post" name="new_user_form">
<table>
<tr>
<td>
<table>
<tr>
<td>Username:</td>
<td><input name="Username" type="text"></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input name="Email" type="text"></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="Password" type="password"></td>
</tr>
</table>
<p><input type="submit" name="submit" value="submit"></p>
</td>
</tr>
</table>
</form>
</body>
</html>
new_user.asp
=========
<%@ Language=JScript%>
<%
var username = Request.Form("Username")
var email = Request.Form("Email")
var password = Request.Form("Password")
var xmlDoc=Server.CreateObject("MICROSOFT.FreeThreadedXMLDOM");
xmlDoc.async="false";
xmlDoc.load(Server.MapPath("/members.xml"));
var nodeList = xmlDoc.getElementsByTagName("members");
if(nodeList.length > 0){
var parentNode = nodeList(0);
var memberNode = xmlDoc.createElement("member");
var usernameNode = xmlDoc.createElement("username");
var emailNode = xmlDoc.createElement("email");
var passwordNode = xmlDoc.createElement("password");
usernameNode.text = username;
emailNode.text = email;
passwordNode.text = password;
parentNode.appendChild(memberNode);
memberNode.appendChild(usernameNode);
memberNode.appendChild(emailNode);
memberNode.appendChild(passwordNode);
xmlDoc.save(Server.MapPath("/members.xml"));
}
Response.Redirect("http://www.google.co.uk")
%>
members.xml
=========
<members>
<member>
<username>thomas</username>
<email>[email protected]</email>
<password>123456</password>
</member>
</members>