timmeh1 Posted October 11, 2008 Share Posted October 11, 2008 Hi i'm trying to put together a simple registration page for a school assignment, but am having alot of trouble trying to figure out the dom library, at the moment my code looks something like this, <?php //script to register new users. //import validation methods include_once 'validation.php'; //COLLECTING FORM DATA IN GLOBAL VARIABLES FROM REGISTER.HTML $username = $_POST['username']; $password = $_POST['password']; $fName = $_POST['fName']; $dob = $_POST['dob']; $program = $_POST['program']; $programExpires = $_POST['programExpires']; $sNumber = $_POST['sNumber']; $email = $_POST['email']; $address = $_POST['address']; $phoneNo = $_POST['phoneNo']; $msg=""; $flag=0; //all my validation code goes here // //open a xml document for writing $doc = new DOMDocument(); $doc->load( 'users.xml' ); $user = $doc->getElementsByTagName( "user" ); $element1 = $user->createElement( "username" ); $user->appendChild( $element1 ); $element2 = $user->createElement( "password" ); $user->appendChild( "$element2" ); $element3 = $user->createElement( "firstname" ); $user->appendChild( "$element3" ); $doc->saveXML(); ?> i've just started trying to get the writing to xml to work, but keep getting stuck I find heaps of examples on the internet that will create a new DOM document from scratch, but i want to just add a new user to my current xml document. which is layed out like this: <?xml version="1.0"?> <users> <user> <username>test</username> <password>password</password> <firstName>name1</firstName> <dateOfBirth>10/10/1990</dateOfBirth> </user> <user> <username>test2</username> <password>password</password> <firstName>name2</firstName> <dateOfBirth>10/10/1991</dateOfBirth> </user> </users> any help would be great! thanks Tim Link to comment https://forums.phpfreaks.com/topic/127941-help-with-dom-putting-post-data-into-a-xml/ Share on other sites More sharing options...
timmeh1 Posted October 11, 2008 Author Share Posted October 11, 2008 bump, no takers? I'm still struggling to get this to work for me I have a login page that reads the xml fine but the registration dislikes me =/ Link to comment https://forums.phpfreaks.com/topic/127941-help-with-dom-putting-post-data-into-a-xml/#findComment-662585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.