Php, macromedia flash, mysql and Flash

  • Zorrotwee
  • Born
  • Born
  • No Avatar
  • Joined: Jun 19, 2010
  • Posts: 1
  • Status: Offline

Post June 19th, 2010, 7:03 am

If been reading tons of tutorials on this and tried it on multiple ways, but it doesn't seem to be working. Why is that?
Can enybody help me out.

This is the script I came out with:


1. MySQL:
- i've created a table userLogin with 3 colums : id, username, password

2. Flash:
I got a very simple form being: 1 button btn_ok, 2 input fields named txt_login and txt_password, 1 dynamic foeld txt_result
In the first frame of scene 1 this script.

Code: [ Select ]
btn_ok.onRelease = function() {
var myLogin:String = txt_login.text;
var myPassword:String = txt_password.text;
maVariable = new LoadVars();
maVariable.var_login = myLogin;
maVariable.var_password = myPassword;
maVariable.onLoad = function() {
if (maVariable.allow == "1") {
//actions
} else {
txt_result.text = "Login/Password incorrect";
}
};
maVariable.sendAndLoad("login.php", maVariable, "POST");
};
  1. btn_ok.onRelease = function() {
  2. var myLogin:String = txt_login.text;
  3. var myPassword:String = txt_password.text;
  4. maVariable = new LoadVars();
  5. maVariable.var_login = myLogin;
  6. maVariable.var_password = myPassword;
  7. maVariable.onLoad = function() {
  8. if (maVariable.allow == "1") {
  9. //actions
  10. } else {
  11. txt_result.text = "Login/Password incorrect";
  12. }
  13. };
  14. maVariable.sendAndLoad("login.php", maVariable, "POST");
  15. };



3. PHP: (login.php)

PHP Code: [ Select ]
<?php
session_start() ;
 
$login = $_POST["var_login"] ;
$password = md5($_POST["var_password"]);
 
if ( $login != '' && $password != '' )
{
$requete = "SELECT username FROM userLogin WHERE username = '$login' AND password = '$password'" ;
 
$server = "localhost";
$basededonnees = "fa225635" ;
$utilisateur = "******" ;
$mdp = "fa225635_Members" ;
 
$connection = mysql_pconnect($server,$utilisateur, $mdp) ;
$choix_db = mysql_select_db($basededonnees, $connection) ;
$resultat = mysql_query($requete,$connection) ;
mysql_close($connection);
 
$result = mysql_fetch_array( $resultat ) ;
 
if ( $result['username'] == $login )
{ echo 'allow=1' ; }
else
{ echo 'allow=0' ; }
}
else { echo 'allow=0' ; }
?>
  1. <?php
  2. session_start() ;
  3.  
  4. $login = $_POST["var_login"] ;
  5. $password = md5($_POST["var_password"]);
  6.  
  7. if ( $login != '' && $password != '' )
  8. {
  9. $requete = "SELECT username FROM userLogin WHERE username = '$login' AND password = '$password'" ;
  10.  
  11. $server = "localhost";
  12. $basededonnees = "fa225635" ;
  13. $utilisateur = "******" ;
  14. $mdp = "fa225635_Members" ;
  15.  
  16. $connection = mysql_pconnect($server,$utilisateur, $mdp) ;
  17. $choix_db = mysql_select_db($basededonnees, $connection) ;
  18. $resultat = mysql_query($requete,$connection) ;
  19. mysql_close($connection);
  20.  
  21. $result = mysql_fetch_array( $resultat ) ;
  22.  
  23. if ( $result['username'] == $login )
  24. { echo 'allow=1' ; }
  25. else
  26. { echo 'allow=0' ; }
  27. }
  28. else { echo 'allow=0' ; }
  29. ?>
Moderator Remark: added code tags
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 19th, 2010, 7:03 am

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post July 1st, 2010, 2:04 am

Test both of your scripts and see if they work independently.
Test the php file using $_GET instead of $_POST and pass the parameters in the browser link like: http://server/login.php?var_login=xxx&var_password=yyyy
and see if the desired outcome is obtained.
My best guess is that the flash file is the one making problems, since you declare maVariable inside the function btn_ok.onRelease, and also the onload function is declared there as well (maVariable.onLoad = function() {... )
This way it might be lost, so just move out of the function both of them.
Code: [ Select ]
maVariable = new LoadVars();
maVariable.onLoad = function() {
if (maVariable.allow == "1") {
//actions
} else {
txt_result.text = "Login/Password incorrect";
}
};

btn_ok.onRelease = function() {
....
}
  1. maVariable = new LoadVars();
  2. maVariable.onLoad = function() {
  3. if (maVariable.allow == "1") {
  4. //actions
  5. } else {
  6. txt_result.text = "Login/Password incorrect";
  7. }
  8. };
  9. btn_ok.onRelease = function() {
  10. ....
  11. }
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 64 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.