buonasera...riscontro un problema con un tutorial di autenticazione con amfphp..
in pratica ho un filmato flash un file php(flashcommtest.php) che ho messo nella cartella service..il filmato flash si appoggia ad un file main.asc
qui lo potete scaricare..
il mio problema è che mi da un errore quando lo faccio girare in locale...
http://localhost/amfphp/register_log...shcommtest.swf
mi esce sul browser un'avviso dato da una finestra dal filmato che mi dice: NetConnection.Connect.Rejected
quindi non si collega al db...questo il file highscores.php dove dovrei mettere i dati esatti per farlo collegare...il mio db si chiama
register_login_amfphp) la mia tabella
userlogin)
codice:
<?php
class flashcommtest
{
/** mysql var access */
var $db_host = 'localhost';
var $db_name = 'register_login_amfphp';
var $db_user = 'root';
var $db_pwd = '';
/** class constructor */
function flashcommtest(){
// create the connection to DB
$this->connection = @mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
// select the database "test"
@mysql_select_db( $this->db_name );
// define the method table for defining flash remoting available methods
$this->methodTable = array();
$this->methodTable["isValidUser"] = array(
"description" => "validate user in mysql table",
"access" => "remote",
);
$this->methodTable["addUser"] = array(
"description" => "Add user in mysql user table",
"access" => "remote",
);
}
/** check if username exists into the table */
function isValidUser($username, $password){
if($this->connection){
$query = sprintf("SELECT * FROM userlogin WHERE username = '%s' and userpassword = '%s'", $username, $password);
$result = mysql_query($query);
if(mysql_num_rows($result) > 0){
return true;
} else {
return false;
}
} else {
return false;
}
}
/** register a new user */
function addUser($username, $password){
if($this->connection){
$query = sprintf("INSERT INTO userlogin set username = '%s', userpassword = '%s'", $username, $password);
$result = @mysql_query($query);
return $result;
if($result){
return true;
} else {
return false;
}
} else {
return false;
}
}
}
?>
questo il codice del file main.asc:
codice:
/**
* flash comm server & flash remoting example
* How to use a simple flash comm server with
* a remoting application inside
*/
// load the remoting classes
load("netservices.asc");
// on application started
application.onAppStart = function(){
trace(' -------------------------------- ');
trace('application started: ' + this.name);
trace(' -------------------------------- ');
// set the default gateway URL
NetServices.setDefaultGatewayUrl("http://localhost:8080/flashservices/gateway.php");
this.gatewayconn = NetServices.createGatewayConnection();
}
// once a new client connects
application.onConnect = function( clientObj ){
clientObj.validuser = false;
// set in the client object the remoting services informations
// and assign a default handler for the remoting calls (AMFPHPResult)
clientObj.serv = this.gatewayconn.getService("flashcommtest", new AMFPHPResult( clientObj ) );
// function called from an swf client
clientObj.validateUser = function( username, password ){
this.serv.isValidUser( username, password );
}
// function called from an swf client
clientObj.registerUser = function( username, password ) {
this.serv.addUser( username, password );
}
// accept the client connection
this.acceptConnection( clientObj );
}
/**
* Remoting Object
* Default responder object for remoting calls
*/
function AMFPHPResult( client ) {
// set the client object
this.client = client;
}
AMFPHPResult.prototype.isValidUser_Result = function( data ){
this.client.validuser = data;
// send back the results to the client object
// by calling a method inside the netconnection object
this.client.call("isValidUser_Result", null, data);
}
AMFPHPResult.prototype.addUser_Result = function( data ){
this.client.validuser = data;
// send back the results to the client object
// by calling a method inside the netconnection object
this.client.call("addUser_Result", null, data);
}
questo nel filmato flash sul fotogramma:
codice:
// redirect user to the chat frame
function gotoChat(evt){
trace('gotoChat');
_root.gotoAndStop('logged');
}
// redirect user to registration frame
function userChoice(evt){
trace('userChoice')
if(evt.detail == 1){
_root.gotoAndStop('register');
}
}
// respond to a remote status messagge
function nc_Status(info:Object):Void{
switch(info.code){
case 'NetConnection.Connect.Failed':
case 'NetConnection.Connect.Rejected':
// connection failed
mx.controls.Alert.show(info.code, "Status", _root, null, "", mx.controls.Alert.OK);
break
case 'NetConnection.Connect.Success':
// connected
_root.gotoAndStop('intro');
break;
}
}
// create the netconnection object
var nc:NetConnection = new NetConnection()
// assign the hander for the onStatus messages
nc.onStatus = nc_Status
// handler for remoting calls
nc.isValidUser_Result = function( data ){
if( data == true ){
mx.controls.Alert.show("Valid user!", "Success", mx.controls.Alert.OK, _root, gotoChat);
} else {
var msg:mx.controls.Alert = mx.controls.Alert.show("Not a valid user, do you want to register a new user?", "Error", mx.controls.Alert.YES | mx.controls.Alert.NO, _root, userChoice);
msg.setStyle("themeColor","haloOrange");
}
}
nc.addUser_Result = function( data ){
if( data == true ){
mx.controls.Alert.show("Registration success!", "Success", mx.controls.Alert.OK, _root, gotoChat);
} else {
var msg:mx.controls.Alert = mx.controls.Alert.show("There were problems registering the new user, please try with a different username", "Error", mx.controls.Alert.OK, _root, null);
msg.setStyle("themeColor","haloOrange");
}
}
// finally connect to flash comm
nc.connect("rtmp:/sample_remoting");
stop();
dove devo andare a mettere le mani per farlo girare in locale?
grazie mille...ciaociaociao