PDA

View Full Version : PHP/mySQL login frustration



goingNuts
April 23rd, 2005, 06:20 PM
ok, i'm pretty much doing the tutorial verbatim, it appears everything is working, but my movie doesn't advance! the only difference between the tutorial and my movie is that my login is in a movie instead of on the main timeline, but i have addressed that by changing

_root.checklog -> this.checklog

anyone that could help? i've been freaking out about this for too long...

here's the code on frame 1:

stop();
userinput.restrict="a-zA-Z0-9";
Selection.setFocus(userinput);
passinput.restrict="a-zA-Z0-9";
status="Enter your information and submit";
this.onEnterFrame = function () {
if(this.checklog == 1){
gotoAndStop(2);
}
if(this.checklog == 2){
gotoAndStop(3);
}
}

here's the PHP:

<?

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

//connect to database
if ($user && $pass){
mysql_pconnect("server","username","password") or die ("didn't connect to mysql");
mysql_select_db("mydb") or die ("no database");
//make query
$query = "SELECT * FROM mytable WHERE username = '$user' AND password = '$pass'";
$result = mysql_query( $query ) or die ("didn't query");

//see if there's an EXACT match
$num = mysql_num_rows( $result );
if ($num == 1){
print "checklog=1";
} else {
print "checklog=2";
}
}
?>

reddo
April 23rd, 2005, 10:57 PM
dude, iam also having a problem, mine just say"redirecting from localhost" in the status bar and nothing happens after that, iam not sure if the connection is there.

CyanBlue
April 23rd, 2005, 11:00 PM
Howdy... :)

You might want to add a textField to output the value of the 'checklog' variable within the onEnterFrame loop... (I am not sure if you really need that onEnterFrame loop though... But I am not aware of that tutorial that you are reading...)

Also, remember that all the variables that are coming from the external source(text file or PHP script for example) are considered as 'string', so you might need to change that if statement with the quotes like this... (The same goes with the '2'...)


if (this.checklog == "1"){

goingNuts
April 23rd, 2005, 11:33 PM
Howdy... :)

You might want to add a textField to output the value of the 'checklog' variable within the onEnterFrame loop... (I am not sure if you really need that onEnterFrame loop though... But I am not aware of that tutorial that you are reading...)

Also, remember that all the variables that are coming from the external source(text file or PHP script for example) are considered as 'string', so you might need to change that if statement with the quotes like this... (The same goes with the '2'...)


if (this.checklog == "1"){


my status bar says "transferring from site..." which is why i think the PHP/ mySQL is working, but the movie is not. supposedly, the onEnterFrame continuously checks the checklog to see where it's at.

the tutorial is under PHP and Flash in the tutorials section.

i'm gonna try that textField idea. thanks for the response.

goingNuts
April 24th, 2005, 12:04 AM
nope, that wasn't it...

do you have to escape the quotes in PHP? like, where it says 'pass'"

i think it's got to be the variable going from PHP to flash.

goingNuts
April 24th, 2005, 04:39 AM
i'm an idiot...

i had the friggin' path to the movie clip wrong the whole time...

sorry to waste everyone's time for those of you who posted.