Developing Flash/Database interaction using Dreamweaver. Pt I: User Authentication (updated) Support Product Page

This topic was archived

login problem

Reported 20 Feb 2007 09:05:57
1
has this problem
20 Feb 2007 09:05:57 ron shtigliz posted:
hi
i have a problem with the login.
it accept everything i enter even if its not in the database.
i checked the code again and again and tried several things, but got no answer.

this is my geting.php:

<?php require_once('Connections/agentConn.php'); ?>
<?php
if (!function_exists("GetSQLValueString") {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string" ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "" ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "" ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "" ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "" ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "" ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$colname2_userLogin_rs = "1";
if (isset($_POST['PASSWORD'])) {
$colname2_userLogin_rs = (get_magic_quotes_gpc()) ? $_POST['PASSWORD'] : addslashes($_POST['PASSWORD']);
}
$colname_userLogin_rs = "1";
if (isset($_POST['USER_ID'])) {
$colname_userLogin_rs = (get_magic_quotes_gpc()) ? $_POST['USER_ID'] : addslashes($_POST['USER_ID']);
}
mysql_select_db($database_agentConn, $agentConn);
$query_userLogin_rs = sprintf("SELECT * FROM users WHERE users.USER_ID = %s AND users.PASSWORD=%s", GetSQLValueString($colname_userLogin_rs, "int",GetSQLValueString($colname2_userLogin_rs, "int");
$userLogin_rs = mysql_query($query_userLogin_rs, $agentConn) or die(mysql_error());
$row_userLogin_rs = mysql_fetch_assoc($userLogin_rs);
$totalRows_userLogin_rs = mysql_num_rows($userLogin_rs);
?>
validuser=<?php echo $totalRows_userLogin_rs ?>
<?php
mysql_free_result($userLogin_rs);
?>

and this is the code in the first frame of the action layer:


//Stop here at the login-screen
stop();

//Define relative URL
_global.basehref = "localhost/dmxPart2/";
//_global.basehref="";

//Define a user authentication function

loginUser = new Object();
loginUser.click = function(){
//Define LoadVars() object to store sent and received data
loginInfo = new LoadVars();
if (_root.USER_NAME_txt.text!="" && _root.PASSWORD_txt.text!=""{
loginInfo.USER_NAME=_root.USER_NAME_txt.text;
loginInfo.PASSWORD=_root.PASSWORD_txt.text;
loginInfo.sendAndLoad(basehref+"getin.php", loginInfo, "POST";
loginInfo.onLoad = function(success) {
if (success) {
trace(loginInfo.validuser)
if (loginInfo.validuser == "0" {
//Invalid user name and/or password
trace("Invalid user";
} else if (loginInfo.validuser == "1" {
gotoAndPlay(2);

}
} else {
//Error connecting to the database or loading data
trace("Error connecting to the database";
}
};
}}

/*Use addEventListener method to trigger the authentication function when the Log-in button is clicked
*/
Login_btn.addEventListener("click", loginUser);


/*Define validation function which checks the value of the validuser variable as well as readonly _url property of the Flash movie. Note that this value is hardcoded (!!!)and will be different on your machine.It is an additional security step to ensure that the movie can not be run from any location other then your web server.
The following line will output your "_root._url" when you test your movie in Flash.
Copy and paste it to replace the current value.
*/
trace(_root._url)


function validateRequest(){
if(_root._url!="file:///C|/program_files/wamp/www/dmxPart2/flash%5Fagent.swf" || loginInfo.validuser != "1"{
gotoAndPlay(3);
}
}

can you please please help?


best regards

ron

i never worked with a "form base", can you explain what it is and how do i use it? maybe a seperate tutorial?

Replies

Replied 22 Feb 2007 22:29:16
22 Feb 2007 22:29:16 Alex July replied:
ron,
Please replace "USER_ID" with "USER_NAME" in your entire getin.php and see if it fixes the problem.

If that doesn't work please describe the following:
1. What do you see when you view your getin.php in the browser (using your local server)?
2. What happens when you try to log-in while testing the movie in Flash?

Also please forward to me your .fla file so I can take a look.
To forward the file please click the Email Poster button above this post. Then in the pop-up window copy my email and using your email client send me the attachment.

The basehref is just a variable which you can quickly change and to update all absolute links in your Flash applicaiton.

Hope this helps.

Edited by - ajuly on 22 Feb 2007 22:40:54

Reply to this topic