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.
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");
};
3. PHP: (login.php)
<?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' ; }
?>