transfert variable flash vers php ( mysql)
Bonjour,
Je suis débutant en flash et je voudrai comprendre pourquoi je n'arrive pas à faire fonctionné un exemple de formulaire, qui envoi des données vers une base...
Je cherche depuis 3 jour et rien à faire !
Je n'ai pas touché au code à part pour changer dans l'as le chemin de mon fichier php, et dans le fichier php mon include pour les paramètres de connexion à la base.
Le problème qui se pose est que le message d'erreur :
"Vous devez fournir le user et le pwd" apparait alors que je rentre bien les 2 identifiant dans l'animation flash...
Voici le code :
Flash:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| stop();
_root.prevloc=null;
monitor.onEnterFrame=function(){
//Cette fonction vérifie en permanence où se trouve le focus
//de manière à démarrer et stopper des animations
var loc=Selection.getFocus();
if(loc == null){
userarea.gotoAndStop(1);
passarea.gotoAndStop(1);
pwdtext.gotoAndStop(1);
usertext.gotoAndStop(1);
}
if(loc == "_level0.user" and loc != _root.prevloc){
if(_root.ErrorContainer != undefined){
_root.ErrorContainer.removeMovieClip();
}
usertext.gotoAndPlay(2);
pwdtext.gotoAndStop(1);
userarea.play();
passarea.gotoAndStop(1);
}
if(loc == "_level0.password" and loc != _root.prevloc){
if(_root.ErrorContainer != undefined){
_root.ErrorContainer.removeMovieClip();
}
usertext.gotoAndStop(1);
pwdtext.gotoAndPlay("2");
userarea.gotoAndStop(1);
passarea.play();
}
_root.prevloc=loc;
}
valider.onPress=function(){
//Cette fonction exécute le script PHP et capture toute erreur possible
if(userpass.length <= 5){
var PhpObject= new LoadVars();
PhpObject.username=_root.username;
PhpObject.userpass=_root.userpass;
PhpObject.onLoad=function(success){
if(success){
if(this.error != undefined){
ShowError(this.error);
}
else{
_root.gotoAndPlay(2);
}
}
else{
ShowError("Erreur durant le chargement");
}
}
if(firstvisit.checked){
PhpObject.new_user=1;
}
PhpObject.sendAndLoad("http://localhost/testform/flashphp.php",PhpObject,"POST");
}
else{
ShowError("Le mot de passe doit faire moins de 6 car.");
}
}
//Cette fonction crée des MC dynamiquement pour afficher l'erreur
//Elle crée un MC par lettre composant le message d'erreur, le tout dans un MC vide
function ShowError(errmsg){
if(_root.ErrorContainer != undefined){
_root.ErrorContainer.removeMovieClip();
}
_root.createEmptyMovieClip("ErrorContainer",2);
_root.ErrorContainer._x=10;
_root.ErrorContainer._y=90;
_root.ErrorContainer.attachMovie("errormsgMC","ErrorLetter0",10);
_root.ErrorContainer.errorletter0.letterMC.letter.text=errmsg.charAt(0);
_root.ErrorContainer.errorletter0._x=0;
_root.ErrorContainer.errorletter0._y=0;
for(i=1;i < errmsg.length;i++){
_root.ErrorContainer.ErrorLetter0.duplicateMovieClip("ErrorLetter"+i,10+i);
_root.ErrorContainer["ErrorLetter"+i].letterMC.letter.text=errmsg.charAt(i);
_root.ErrorContainer["ErrorLetter"+i]._x=(Xpos+(int(i)*8));
_root.ErrorContainer["ErrorLetter"+i]._y=0;
}
} |
Php :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?
include "dbconfig.php";
if(!empty($_POST['new_user'])){
mysql_query("insert into users(username,userpwd) values('".$_POST['username']."','".md5($_POST['userpass'])."')")
or die("&error=".mysql_error()."&");
exit;
}
if(!empty($_POST['username']) && !empty($_POST['userpass'])){
$res=mysql_query("select username from users where username='".$_POST['username']."' and userpwd='".md5($_POST['userpass'])."'")
or die("&error=".mysql_error()."&");
if(mysql_num_rows($res)!=1){
echo "&error=User/pwd invalide& ";
}
}
else{
echo "&error=Vous devez fournir le user et le pwd&";
}
?> |
Pleaz help !