I’ve been trying to get this working for about two days doing searches and trying tuts and ideas and them customizing them to what I want and I cant get the **************** thing to work.
Here’s the deal:
I want to have a login page in flash that will take a user name and password,
2.throw it to a php file,
3.have the php file check for a match in mySQL and have that php file send back a var saying auth=1 (approved) or auth=0 (no dice),
Then have flash say “okay, auth==1, gotoAndPlay(secret stuff)” or “hey, auth==0, gotoAndPlay(no soup for you)” I mean it seams SO EASY!! RIGHT!!???
The php script that I’ve attached is one that does exactly what I want to have flash do. This script works in HTML!! Anybody wanna take a stab?
I think it might be easier to have a different order of execution… you could have the PHP script pull the usernames and passwords out of a database and print them.
Then the flash file would check if the username and password matched its list allowed names.
I have no idea how to implement this, as I havn’t really got into PHP yet. I just think that that approach would be easier.
Thanks for looking NJS! I actually wouldn’t know how to print out everything from the database to Flash and make a list that way, I figure you would have to make an array for Flash to look at. I didn’t see you post when I posted, but the HTML version basically looks for a row in the dbase with a matching name and password, if it exists, you win.
I’ll keep that in mind if all else fails; however, then I would have to learn how to post an array of variable to Flash when I can’t even get 1 in!! I believe that’s my main problem is the communication between PHP and Flash…Boo…
instead of having the headers redirect the HTML page, I want a variable set and read by flash like auth=1. That way, I can put an if/else loop checking auth and sending the user wherever.
Thanks EYEZ!! Where’s your footer? Anyhow; I tried something close to that, but not exactly. Will the one loadVariblesNum command on my button on the first frame of the movie pull back that ‘auth’ variable, or do I have to use LoadVars();? The tut on kirupa only sends a variable to a movieClip with a text box using ‘this’. What if I just want to load a variable to use here and there in Flash? (In this case, only once, but in future projects I may have to use the var more than once).
Alright…I’m so close I can smell it! and it smells good!! Eyes, I took your advice and closed the mysql session and changed that last statement. Now, I made a quick little movie to see if I could get it to work, and I cant. However, if you put in a working set (user/pass) and then run the php script rigth away, it will echo the correct thing in the browser - so I think I’m talking to it!! Now, getting the ‘&auth=1’ back into flash, I think I’m having a problem…Please help me with this last thing and I promise to leave you guys alone for at least a week!!
No dice, but thanks for the try. You did give me a good idea to load the variables into an empty movieClip. I will continute to try - thanks anyway eyez!! (and put your footer back! I miss messing with it!!).
Alright, I had a look at eyezberg his version and the thing with php is that it can be rather tricky into loading the variables into the textfields. Have you made a plain document where textField gets filled from your php? Anyhow I might have a good example for you for a nice login. But you will have to wait once I get home but I think I can help you out
Yeah, that’s half the prob. The other half of the prob is when you put in the correct stuff, it’ll still get stuck… My problem is getting the variable ‘auth’ from the PHP back into Flash. Flash is posting, but nothing’s comming back. The cheese slid off the cracker. Any ideas?
i am by far no php expert but this is a script that display’s my php news into my flash file
// PHP FILE
$title = ""; // I do this to tell me that $title is going to be a string.
for ($i=0; $i <$num_results; $i++){ // for loop
$row = mysql_fetch_assoc($result); // You know what this is
$title .= $row['date'] . "
". $row['description'] . "
";
}
print "title=".$title; //print it out so Flash can read it.
?>
then in my flash file, i have a textfield “title” which displays the info, by simply loading vars.
not sure if this will help but this is how i get my info into flash. how bout posting your php file, maybe we can intergrate the script.
Actually, I changed the last part of the code to what Eyezberg told me:
} else {
echo "&auth=$auth";
}
which is the same as what yours is. You can use print or echo and joint your string together with a ‘.’ - I think still think the problem is in my flash movie and how I’m loading it in (or not loading it in, in this case).
Loading PHP to a txt box is easy. However, I’m trying to load in a variable that I can use at any time anywhere in the movie. That’s what I need to do is try to load the answer into a text box without trying actions right away. I’m gonna do that, then edit this post to see if PHP is actually talking to flash or not.
Frame 5 says ‘you’re in’ and frame 4 is a loop that goes back to the actions above.
HERE’S THE KICKER!! When you play it, it sends the info to PHP, gets into the loop, a fraction of a second later, flash pulls the variable from the PHP and pops it into the box (emphatically named ‘crap’). SO, everything works, except Flash is ignoring the fact that auth==1 and should goto(5)… EEERRRRR!!
I’ve tried it with and without the quote marks around the 1, in case that caught your eye.
So, the PHP works, mySQL works, it’s flash that isn’t working. But why?? This is the question I ponder…
Thank you Jubba, however, I need it tied to mySQL because it’s for a website I’m designing. I believe I saw that same thing that you made in the forum somewhere in my research.
I’m going to make an HTML page for my client to add in names and passwords to the database so I won’t have to rewrite the PHP each time they get a new client.
I don’t know if you looked at my fla, but on that same frame is says _root.crap=_root.auth (crap is the text box) and it works, the variable is comming back correctly to Flash, but when I put it in an if/else statement in a loop, it doesn’t work.
Ripping my hair out!!!
Well, if anything, I’ll just make a popup window and do that part in HTML. Quite honestly, the client would never know, nor care. If no one else has any ideas, I thank you all for your time and suggestions!!!