PDA

View Full Version : Username and password protection


lelales
05-14-2005, 07:58 PM
Okay, I'm completely clueless on this, maybe someone can point out a tutorial.

I think I know how to make a page secure by hardcoding the username and password into the Flash file, but the client wants to be able to update these fields. So I guess I would need some PHP and a database.

Or maybe just a flat file that says."[as]
<php>
print "&username=" . sean . "&password=".password");

</php>

But how can I place this info into variables for Flash from a flat text file?

thanks

snapple
05-14-2005, 10:05 PM
Dead simple - just use a flat file, i wouldn't bother with a database driven solution, unless it's going to ahve loads of different username and passwords and will be used by lots of different people, like a CMS.

Create 2 text boxes, put them on the root timeline and give them instance names of:

username and pwd

Create a button and place it on the root timline too.

Put this in the 1st frame:


var loginVars:LoadVars = new LoadVars();
_global.u = "";
_global.p = "";

loginVars.onLoad = function( success:Boolean ):Void
{
if( success )
{
this.decode( this.toString() );
p = this.pwd;
u = this.username;
}
else
{
trace( "Error LoadVars" );
}
};

loginVars.load( "details.txt" );

_root.submit_pb.onRelease = function( Void ):Void
{
if( username.text == u && pwd.text == p )
{
trace( "Allowed in" );
}
else
{
trace( "Not allowed in" );
}
}


Create a text file called "details.txt" in the smae directory. Put this in it:

&username=computer&pwd=12345678

Should all work.

Regards, snapple

lelales
05-14-2005, 10:30 PM
That's exactly what I was looking for.

thanks again. :p