SimpleXML Problem
Posted: Fri Jul 27, 2007 1:12 pm
I'm making a XML-based user system, I am having problems with my function for adding a user...It seems to replace the last user with the one I try to add, here's my code:
($users is the XML file, loaded with simplexml_load_file())
The user file is similar to this:
Code: Select all
function add_user($username, $password)
{
global $users;
if(!user_exists($username))
{
$newuser = $users->addChild('user', '');
$newuser->addChild('username',$username);
$newuser->addChild('password',hash('sha512', base64_encode($password)));
}
}The user file is similar to this:
Code: Select all
<users>
<user>
<username>abc</username>
<password>(password)</password>
</user>
<user>
<username>testuser123</username>
<password>(password)</password>
</user>
</users>