hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
    Articles
  Flash button as Flex icon  Flex form by email  Hello Remoting with AS3  AS3 Saving data from Flash  AS3 Loading data into Flash  Fire Effect  Contact form  Dragable buttons  Hello World with openamf  Loading helper classes  Upload with Flash 8  Transitions effects  Snapshot with Flash 8  Hello World Remoting AS2  Flash AS2 Remoting Connector  Saving data from Flash  Loading data into Flash  FlashCom & Remoting login  Cell Renderer API  Editing a table using remoting components  Flash MX2004 web service classes  Browsing a catalog  amfphp Documentation  Hello World Remoting  Online Store with AMFPHP  Flash clients for Web Services  Web Service Walk Though with NuSoap  Popup windows in flash with javascript  Installing Apache/PHP  MoreOver News Feeds  Load Edit Save Text Files via CGI  Save Movie Clip Postion via PHP and MySQL
Current Page (1) Next Page >>  View Article Example >> 1 | 2
Untitled Document

Flash Communication and Flash Remoting login

Folder structure

The expected folder structure is:

Web structure:

root (root folder of your web server)
  flashservices (amfphp library)
  login (main folder)
    login.htm
    login.swf
   gateway.php
       services (services folder)
            login.php
            inc_sql.php

FlashCom structure

<Flashcom installation folder>
   applications (in this folder are all your FlashCom app's)
       login (folder for our app)
           main.asc

If you unzip the examples files, you will see the Web structure and inside the login folder, main.asc. So you need to create the login folder inside your FlashCom applications folder and move main.asc there.

The database

We will use a table with only one row in the Users table:

CREATE TABLE users (
PkUser int(11) NOT NULL auto_increment,
Username varchar(255) NOT NULL default '',
Password varchar(255) NOT NULL default '',
PRIMARY KEY (PkUser)
) TYPE=MyISAM;

INSERT INTO users VALUES (1, 'test', 'test');

You can run install.php to create the database and the table. If you decide to setup the example without install.php, you can use users.sql file who holds all the necessary SQL (but you need to create the database first)

The Remoting Class: authenticate.php

We will use a Remoting class named login in a folder named services, with only one method: authenticate. Again, if you don't know how to setup an amfphp Remoting class, read Hello World Remoting. Here's our product class:


<?php
include_once("inc_sql.php");
class 
login{

    var 
$dbhost HOSTNAME;
    var 
$dbname DATABASE;
    var 
$dbuser USERNAME;
    var 
$dbpass PASSWORD;

      function 
login(){
        
$this->methodTable = array(
            
"authenticate" => array(
              
"description" => "Check for a username and password",
              
"access" => "remote"// available values are private, public, remote
              
"arguments" => array ("username""password")
            )
        );
         
// Initialize db connection
        
$this->conn mysql_pconnect($this->dbhost$this->dbuser$this->dbpass);
        
mysql_select_db ($this->dbname);

      }            
      function 
authenticate($username$password){
        
$result mysql_query("Select PkUser from users where Username='$username' and Password='$password'");
        if(
mysql_num_rows($result)>0) return true;
        else return 
false;
      }
}
?>

The authenticate method simply query the database passing the username and password the user enters in the Flash movie. The inc_sql.php file holds all the necessary data to connect to the database (modify to match your own needs)

Also we need a gateway.


    <?php
        
//default gateway
        
include "../flashservices/app/Gateway.php";
        
        
$gateway = new Gateway();
        
$gateway->setBaseClassPath("./services/");
        
$gateway->service();
    
    
?>

If you change the folder structure, you need to change gateway.php to match your needs.
Ok, let's move to the FlashCom part

Current Page (1) Next Page >> 1 | 2