Forums

PHP

This topic is locked

PHP / FLASH / MYSQL

Posted 21 Jan 2005 15:14:06
1
has voted
21 Jan 2005 15:14:06 Chad Mr. posted:
I dload Alex July's Tutorial.

Here is what I have:
www.actionfx.net/php/login.html
1) Flash app with two labels, and input fields, and a button.
On frame 1 I have the following code:



code:--------------------------------------------------------------------------------//Stop here at the login-screen
stop();
//Define relative URL
_global.basehref = "localhost/php/actionfx_net";
/* Uncomment the line below and comment the one above
before uploading your files to the server
*/
//_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 both fields have been filled out…
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" {
gotoAndStop(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!="login.swf" || loginInfo.validuser != "1"{
gotoAndStop(1);
}
}

--------------------------------------------------------------------------------

On frame two I have

code:--------------------------------------------------------------------------------////First find out whether the user is even allowed to access this frame
validateRequest();
//Proceed with other instructions
//Use Welcome_txt textfield to welcome the user
Welcome_txt.text="Welcome "+loginInfo.USER_NAME;
//Load or attach other movie clips and do whatever you like.
stop();
--------------------------------------------------------------------------------

Frame two includes a dynamic welcome text field.

2)In my php (gettin.php)

PHP:--------------------------------------------------------------------------------
<?php echo $totalRows_Recordset1 ?>
<?php require_once('Connections/actionfx.php'); ?>
<?php
$colname_Recordset1 = "1";
if (isset($_POST['USER_ID'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST['USER_ID'] : addslashes($_POST['USER_ID']);
}
$colname2_Recordset1 = "1";
if (isset($_POST['PASSWORD'])) {
$colname2_Recordset1 = (get_magic_quotes_gpc()) ? $_POST['PASSWORD'] : addslashes($_POST['PASSWORD']);
}
mysql_select_db($database_actionfx, $actionfx);
$query_Recordset1 = sprintf("SELECT * FROM users WHERE USER_ID = %s AND users.PASSWORD=%s", $colname_Recordset1,$colname2_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $actionfx) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_free_result($Recordset1);
?>

--------------------------------------------------------------------------------


The problem I got, is I got nothing..
I cant get this thing to login. I know I got the database info, because when I was creating the recordset information everything was gravy. Any ideas?

My DB name is ACTIONFX_NET

Replies

Replied 21 Jan 2005 20:36:47
21 Jan 2005 20:36:47 Chris Charlton replied:
<pre id=code><font face=courier size=2 id=code>_global.basehref = "localhost/php/actionfx_net";</font id=code></pre id=code>
I have not seen this used, myself (localhost), but I do notice you have a comment to commenit <i>it</i> out later before uploading to your web server...did you forget to swap the "basehref" var?!? <img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>

Also, <pre id=code><font face=courier size=2 id=code>&lt;?php echo $totalRows_Recordset1 ?&gt;</font id=code></pre id=code> comes first, any reason for that?

More questions lead us to the answer(s). <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 21 Jan 2005 21:27:46
21 Jan 2005 21:27:46 Chad Mr. replied:
I did change that var to " " empty quotes.
Also that recordset is information generated by dreamweaver as in the tutorial. Im not sure about that.

Reply to this topic