# Simple XML login

**URL:** <https://forum.kirupa.com/t/simple-xml-login/305720>\
**Category:** flash\
**Created:** [March 2, 2010, 4:51pm UTC](https://forum.kirupa.com/t/simple-xml-login/305720 "2010-03-02T16:51:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim\_bwfc](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tim\_bwfc](https://forum.kirupa.com/u/tim_bwfc)\
**Post date:** [March 2, 2010, 4:51pm UTC](https://forum.kirupa.com/t/simple-xml-login/305720/1 "2010-03-02T16:51:56Z")

</div>

Hi!

Been experimenting with as3 for a short while and decided to make a small system that requires a login area. I have done lots of research and realise that using PHP and mySQL is a safer way of going around this however for now i just want to create a database using XML to store usernames and passwords in and Flash will then look these up.

I have managed to set up an internal login system with the username and password stored in the fla file, so now want to go one step further.

I did find this code whilst researching on the internet? Would this be appropriate for what i am looking for, and if so what would the xml file look like to work with it?

var loader:URLLoader = new URLLoader();  
loader.addEventListener(Event.COMPLETE, onLoaded);  
loader.load(new URLRequest(“users.xml”));

var xml:XML;  
var usernames:Array = new Array();  
var passwords:Array = new Array();

function onLoaded(e:Event):void  
{  
xml = new XML(e.target.data);  
var il:XMLList = xml.user;

```
for(var i:uint=0;i&lt;il.length();i++)
{
	usernames* = il.username*;
	passwords* = il.password*;
}

```

}

var passField:TextField = new TextField;  
passField.type = TextFieldType.INPUT;  
passField.displayAsPassword = true;  
passField.x = 27;  
passField.y = 97;  
passField.width = 155;  
passField.height = 21;  
addChild(passField);

nameField.addEventListener(MouseEvent.MOUSE\_DOWN, killNameText);  
passField.addEventListener(MouseEvent.MOUSE\_DOWN, killPassText);

function killNameText(e:MouseEvent):void  
{  
nameField.text = “”;  
}

function killPassText(e:MouseEvent):void  
{  
passField.text = “”;  
}  
submit\_mc.buttonMode = true;  
submit\_mc.addEventListener(MouseEvent.MOUSE\_UP, checkInfo);

var loginStatus:Boolean = false;

function checkInfo(e:MouseEvent):void  
{  
for(var i:Number = 0; i \< usernames.length; i++)  
{  
if(nameField.text == usernames\* && passField.text == passwords\*)  
{  
loginStatus = true;  
break;  
}  
else  
{  
loginStatus = false;  
}  
}

```
if(loginStatus == true)
{
	resultText.text = "Congratulations, you are registered!";
}
else
{
	resultText.text = "Sorry, you are not registered.";
}

```

}

Many Thanks,

T
