Php, macromedia flash, mysql and Flash

  • Zorrotwee
  • Born
  • Born
  • Zorrotwee
  • Posts: 1

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

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. }

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 12 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.