PDA

View Full Version : Login System not working as it should be.


ExcellenceGS
04-20-2011, 11:08 PM
Heya Members of Actionscript,

I have been behind my computer for all day long now.
Finally got the login system to actually login but, a major BUT!

I cannot fill anything in Flash input textboxes or else it screws up.

let me give you some examples.


<?php
//My login Script
// declare variables
$user = $_POST['user'];
$pass = $_POST['pass'];
//
// mysql connection variables
$host = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'heathens';
$table = 'egsmembers';
//
// connect to db
$db = @mysql_connect($host,$dbuser,$dbpass) or die("error=could not connect to $host");
$db = mysql_select_db($dbname);
if(!$db)
{
echo "&status=could not connect to $dbname table";
exit;
}
//
// check table
$query = mysql_query("SELECT * FROM $table WHERE USERname = '$user' AND USERpass = '$pass'");
$num = mysql_num_rows($query);
if($num>0)
{
echo "&lerror=ok";

print "&checklog=1";

} else {
echo "&lerror=not ok";
echo "&cool=$host";
echo "&checklog=0";

}
?>

the above works correctly.

now the Flash Part.



// init LoadVars Object
lv = new LoadVars();

// set Variables
lv.user = "egsadmin";
lv.pass = "adminegs";
lv.checklog ="0";
lv.error = "none";


// define onLoad Callback
lv.onLoad = onLoadCallBack;

// send and load variables


// onLoad Callback
function onLoadCallBack(succes)
{
// if succes
if(succes)
{
// trace variables
_root.status.text="Retreiving info"
trace(this.user);
trace(this.pass);
trace(this.checklog);
trace(this.lerror);
trace(this.cool);
_root.status.text="Checking info"
if(this.checklog == 1){
_root.status.text="Succes!"
_root.gotoAndStop(3);
}
if(this.checklog == 0){
_root.status.text="Login Failed, please make sure you have entered the correct Username and Password."
_root.gotoAndStop(2);
}
}

else
{
// loading failed
trace("Loading Error!!");
}
}

stop();

flash button:
on(release){

status.text = "Begin Login Process - Wait...";
lv.sendAndLoad("/localhost/login.php", lv, "POST");
}


it only works when the variables are like this:

// set Variables
lv.user = "egsadmin";
lv.pass = "adminegs";


if I type something in the inputbox in flash I receive this.


<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="MS Reference Sans Serif" SIZE="15" COLOR="#000000" LETTERSPACING="0" KERNING="0">test</FONT></P></TEXTFORMAT>
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="_sans" SIZE="13" COLOR="#000000" LETTERSPACING="0" KERNING="0">test</FONT></P></TEXTFORMAT>
0
not ok
localhost


With the script setup like:
// set Variables
lv.user = "test";
lv.pass = "test";


it showstest
test
1
ok


It just doesn't work when I type text into my "Inputtextboxes".
properties of my "inputtextbox":
username: lv.user
pass:lv.pass

I have no idea how I really can explain this is easy as I just started PHP and MySQL today.

the problem is in Flash I believe, when I type something in the "username" textfield it comes up with a huge script like this, no wonder it cannot compare the variable to the ones inside the database if it's like this...
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="MS Reference Sans Serif" SIZE="15" COLOR="#000000" LETTERSPACING="0" KERNING="0">test</FONT></P></TEXTFORMAT>
I receive all of this within flash with these commandes can also be found in the top Action Script trace(this.user); trace(this.pass);
it's really getting frustrating and I am all out of luck. So maybe you guys could help me out a little?


thanks in advance!


-------
I'm sorry if there are any grammatical/spelling errors.
It's late and I'm sleepy and a bit frustrated!

audiopro
04-21-2011, 02:57 PM
You are setting
lv.user and lv.pass

but tracing

this.user and this.pass

ExcellenceGS
04-21-2011, 03:18 PM
You are setting
lv.user and lv.pass

but tracing

this.user and this.pass

that is correct.

'lv.user' is used to send to the PHP file where it is assigned to the 'user' variable.

Thus I'm tracing the 'user' variable inside the PHP file and I get this output.

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="MS Reference Sans Serif" SIZE="15" COLOR="#000000" LETTERSPACING="0" KERNING="0">test</FONT></P></TEXTFORMAT>

I'm just going to ask this one.

How can I make it so.

I can type something in, the input text fields I use in Flash?
It saves that as a variable and sends to PHP, because this ain't working..

ExcellenceGS
04-21-2011, 03:39 PM
Nevermind.
I fixed it myself! :)

audiopro
04-21-2011, 03:43 PM
How?

ExcellenceGS
04-21-2011, 04:59 PM
My fix was this.

Changed the input textfields in flash.
instance name: userinput
var: user

instance name: passinput
var: pass

Frame which login system occurs:


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(_root.checklog == 1){
_root.gotoAndStop(3);
}
if(_root.checklog == 2){
_root.gotoAndStop(2);
}
}




Flash Submit button:


on (release, keyPress "<Enter>") {
if (user != "" && pass != "") {

status = "Begin Login Process - Wait...";
loadVariablesNum("/localhost/login.php", 0, "POST");
}
}



Maybe it helps for people who need Flash AS2.0, PHP and MySQL login-system.

audiopro
04-21-2011, 05:19 PM
Thanks.
It is always better to finish a thread off with a solution rather than just leaving it hanging.
I prefer Load, with the vars tagged onto the query string rather than Send and load, although I am not sure which is the most secure.