Access control xml-php-mysql


The goal is to control access when a user fills in a form with a login and a password (MD5 Encryption)
This user was previously registered in a MySql database.
Of course, the registration was made using another animation.
This example doesn't concern a newbye because it needs a good understanding. So I do not expand the building objects methodology.
The different stages are gonna describe right now.

Creating Objects

1 - Set up movie size 640x480. Any background color.
Frame rate = 25.

2 - We need to build the following dialog box :

boite de dialogue login mot de passe

This box has been made with : ( see tree )

- a unit for login ( name : login_bloc ) 540x50 _x=320 _y=60
- a rectangle ( name : Shape ) 540x355 _x=320 _y=265
- a label ( name : User Name ) Arial 16 , largeur 88, _x=70 _y=140
- a label ( name : Password ) Arial 16 , largeur 88, _x=70 _y=190
- an input field ( name : username_txt , type : Input, var : user, target toggled )
_x=180 _y=140 w=150 h=20
Click the 5th icon to get a framed background.
- an input field ( name : password_txt , type : Input, var : pwd, target toggled )
_x=180 _y=190 w=150 h=20
Click the 5th icon to get a framed background.
- a button ( name : login_btn , target toggled ) x=255 _y=250 w=150 h=27
- a dynamic text ( name : message_txt, type : dynamic, var message, target toggled )
_x=377 _y=140 w=174 h=70

script animation.

In Scene_1, we place the functions required for MD5 Encryption of password.
I found them on Internet and I don't know who build them.

Enter the following script in Scene_1 :

Remarks :
1 - It's perfectly clear that the password stored in the database was previously encrypted using the same functions.
That means you must use these functions in the flash movie called for registration.
Should I remind you that this example is just to control access of a registered user !

2 - SwishMax2 only supports AS2. Thus, the following code is obsolete for the last Flash release, XML AS2 class has been renamed XMLdocument in AS3 for compatibility reasons.

Enter the fllowing script for button login_btn :

loginXML object, with data["xml"], is used to send a xml document to a php script named checkAccess.php on the server.
The php script ( see further ) sends back a xml document parsed by loginReplyXML object.
This function switches the user depending on LOGINREPLY node attributes.
If xml text is <LOGINREPLY STATUS="OK" SESSION="zzzzzzzz" /> STATUS attribute is OK and Welcome message 'll be displayed.
If xml text is <LOGINREPLY STATUS="FAILURE" /> STATUS attribute is FAILURE and Access denied message 'll be displayed.

PHP script checkAccess

With your favourite text editor, enter the following code and save it as checkAccess.php.

You could first test your movie without using database just writing the xml response.
So, you could read the message variable in the movie, depending on OK or FAILURE.
If you wish to create a movie to register new users don't forget to use the same MD5 encrypting functions.
( See also topic PHP of this site )


Si vous aimez le site


Select a language if you need :

Page chargée en 0.004 sec.

Dernière Modification : Mer 25 Janvier 2017 8:56
Copyright © 1999-2017 Jean-Paul Molina Tous droits réservés.

to Google