PDA

View Full Version : simple flash php authen.



jazzman121
June 4th, 2003, 09:32 PM
here is what i wanna do.. i want to have a log in.. for my flash file.... its got a username field and password field... on submit... it sends the variables of 2 fields to a .php file... which checks if the user name and password match the user name and password in the .php file... it it does... it returns a varaible to the flash file...

here is what my php file is like...


<?php

$pass = $_POST['pass'];
$user = $_POST['user'];

//correct username and password ...

$orguser = "jazzman121";
$orgpassw = "test";


if ($passw==$orgpassw&$user==$orguser) {
$result = "ACCESS GRANTED";
}else {
$result = "ACCESS DENIED";
}
?>


im kinda new to php... so this code might not be right... i guess thats why its not working :sure:

anyways... how should my flash file look like?? please help

thanks... (if i have to change my php... please let me know about that too.. )

jazzman121
June 4th, 2003, 09:33 PM
Im thinking this should be safe... since its serverside soo no one can find out the correct username and password.... ..

and i dont have a database... soo i cant do that .. :( ( if there are other better ways to do this.. please let me know thanks )

Jubba
June 4th, 2003, 11:21 PM
PHP file:


<?php

$pass = $_POST['pass'];
$user = $_POST['user'];

//correct username and password ...

$orguser = "jazzman121";
$orgpass = "test";


if ($pass == $orgpassw && $user == $orguser)
{
echo "result=ACCESS GRANTED";
}
else
{
echo "result=ACCESS DENIED";
}
?>



FLASH:

You need to create a loop to check for the variable and make sure that its not empty. This is MX code since you didn't specify which version you are using...


_root.onEnterFrame = function(){
if(result == ""){
loadVariablesNum("phpPage.php", 0, "post");
}
else if(result == "ACCESS GRANTED"){
//do something correct here....
}
else if(result == "ACCESS DENIED"){
//Send them away here....
}
}


something like that should work. I didn't check tho...