Hello all: I tend not to post in the boards much because I figure I save everyone some time if i just search and try, then try again until it works...but this one is making me loose my mind. I need some help.
Here is the situation;
I am converting a phpnuke (www.phpnuke.com) website to a Flash version, only than rather that trying to build in the flash into the phpnuke, I stripped the phpnuke down, created a main launch page with a main flash movie, and from there I launch popup windows to the php sections. So far, the search funtion and the pages work all great. I have done it so to avoid having to use almost any php/flash interaction other than opening urls with javascript or sending form urls to php pages that open in a separate window. I figure the only thing I would really need to have in my flash as far as php are three things:
1) A way to determine if the user was already member by looking at the cookie and cheking the username/password. This would redirect the user's movie. If a user, skips to a labeled frame with the GUI fully funtional. If not, it played until it gets to a page with either...
2) A login box that cheks with a php script that looks up the database, checks for username/password, then returns either a negative result (not a member/wrong password/username) or positive result (a member) that sets the main user cookie (username, password,email, url, AIM #, etc,..) and then sends the movie to a new location in the Flash movie with GUI fully functional. or...
3) If not a member, a SIgn Up page with a form where all the dababase info is taken, then send to a php script where it is set in the database, the main user cookie is set (same as above) and the user is send to the fully functional GUI.
Ok....so...I am not by any means a PHP coder at all, but I have an eye for reformatting code...I have tried to take some of the phpnuke code and disassemble it to use only the bits I need to produce these three things, but so far I have spent 48 hours and I am quite frustate it. I know I am close, but my lack of php is probably creating problems I don't know:
SO the first thing I need help with is issue 1. I am hoping that by having one of you help me out with 1 Y may figure out 2 and 3 on my own:
Here is the php script I have "created" to check the cookie. It is based on a snippet from the mainfile.php page of phpnuke. (The comments are mine so as to explain what I think it should do)
<?php
if (eregi("checkcookie.php",$PHP_SELF)) {
die();
}
include("config.php"); /*it has all the MySQL settings.
mysql_connect($dbhost, $dbuname, $dbpass);
@mysql_select_db("indie") or die ("Unable to select database"); /*Connects to MySql/table
function loggedin($user) { /function loggedin()
global $prefix;
if(!is_array($user)) { /$user is array
$user = base64_decode($user); /$decode cookie
$user = explode(":", $user); /$explode cookie
$uid = "$user[0]"; /1st cookie value is userID
$pwd = "$user[2]"; / 2nd cookie value is pass
} else { / or....
$uid = "$user[0]"; /1st cookie value set to null?
$pwd = "$user[2]"; /2nd cookie value set to null?
}
$result=mysql_query("select pass from $prefix"._users." where uid='$uid'"); / Seeks MySQL
list($pass)=mysql_fetch_row($result);
if($pass == $pwd && $pass != "") { /Compares
return 1; /if member, returns 1
}
return 0; /*if not member, returns 0
}
?>
Ok. First of all..I have a variable in my movie named "loggedin" that will be set either to 0 (not) or 1 (yes). I want this script to basically check the user's main cookie ($user), decode the cookie string/info , check the password in the database, then return a value to the movie and assign it to the "loggedin" variable.
In my movie I have a frame action in frame 1 that sets the variable "loggedin to 0", then loads the new value from the server (or at least that's what I want to do anyway):
loggedin = 0;
loadVariablesNum ("checkcookie.php?loggedin", 0, "GET");
So what is wrong (how may things are wrong) I know somewhere in there I have the answer, but I just can't figure it out....
Is the PHP script ok?..Should it work as is?...If so, then what about my Load variables action...Am I calling the php script correctly?...
Later on the movie I have a frame action that checks for the value of " loggedin" variable and redirects the user to the proper movie frame...
I can't be this hard. Plase, show me how stupid I am...
Canary