Evening all,
Following from Freddythunders tutorial, I’m trying to make a login in flash. I’m having trouble getting it to work but can’t where I’m going wrong! I presume it’s a typo or some similarly stupid mistake I’m making but have gone back over the tutorial and code I don’t know how many times!
The flash stuff is at http://www.artefactproject.com/kirupa_2.html, the PHP file is then [URL=“http://www.artefactproject.com/pdalogin.com”]http://www.artefactproject.com/pdalogin.com
When I try to log in with the username timmy pass timmy (which works on a seperate site links to the same db, same table), I get redirected to the 3rd frame in the movie, Your name and password don’t match…
(Also I realise that the back button isnt great as it is only the box outline - but will prettify when I get the functionality sorted!)
If someone would be so kind as to look over the code below and point in the right general direction I would be eternally grateful! I’m fairly new to flash/php but really need this to work asap! The login is essential but need not be secure or anything like that!
Thank you in advance!
Edelmh
AS frame 1 of movie:
stop();
userinput.restrict="a-zA-Z0-9";
passinput.restrict="a-zA-Z0-9";
Selection.setFocus(userinput);
status="Please enter your information and submit";
//this enters in directions in your textbox called status
this.onEnterFrame = function () {
if(_root.checklog == 1){
_root.gotoAndStop(2);
}
if(_root.checklog == 2){
_root.gotoAndStop(3);
}
}
//the onEnterFrame constantly checks to see if the PHP
//script has sent the variable 'checklog' back to the
//movie and directs the people accordingly
AS on submit button:
//this will be the action to get your variables from the PHP
on (release, keyPress "") {
//checks to see if there is something in both the name
//and password
if (user != "" && pass != "") {
status = "Begin Login Process - Wait...";
//if you changed the php file name, change it here to!!
loadVariablesNum("pdalogin.php", 0, "POST");
}
}
PHP code:
<?
//this pulls the variables from the flash movie when the user
//hits submit. Use this when your global variables are off.
//I don't know how to toggle global variables, so I just put
//it in all the time ;)
$user=$_POST['u'];
$pass=$_POST['p'];
//connect to database
if ($user && $pass){
mysql_pconnect("host","username","password") or die ("didn't connect to mysql");
mysql_select_db("artefac_database") or die ("no database");
//make query
$query = "SELECT * FROM users WHERE username = '$u' AND password = '$p'";
$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 "status=You're in&checklog=1";
} else {
print "status=Sorry, but your user name and password did not match a user name/password combination in our database. Usernames and passwords are entered in from a different file. Thank you for visiting test login script!!&checklog=2";
}
}
?>