i didnt have any idea to connect as2/as3 with mysql by session login user. i just want to read somedata and input score from swf file to database. i need help how to excute this logic.
i have 2 login user by session CI login,
- 1 users (admin) upload swf file (this work and run swf to the browser)
- users 2 (student) play swf file (working as well)
- on the latest frame i wanted to show in textfield "student name and score" and after that when users click button it will send to database.
im newbie for this, i haved test today on 15.00 WIB, i hope someone can help me
My Answer:
To connect CodeIgniter session with Flash ActionScript, you can follow these steps:
1. In your CodeIgniter controller, after the user logs in, you can store the user's information in the session. For example:
php
$this->session->set_userdata('user_id', $user_id);
$this->session->set_userdata('username', $username);
2. In your Flash ActionScript file, you can use the `URLLoader` class to send a request to a PHP file that will interact with the database. Here is an example of how you can send data to a PHP file:
actionscript
var request:URLRequest = new URLRequest("http://yourdomain.com/save_score.php");
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.user_id = user_id;
variables.score = score;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.load(request);
3. In your PHP file (save_score.php), you can retrieve the session data and save the score to the database. Here is an example of how you can do this:
php
session_start();
$user_id = $_SESSION['user_id'];
$score = $_POST['score'];
// Save the score to the database using CodeIgniter's database functions
By following these steps, you can connect CodeIgniter session with Flash ActionScript and save the user's score to the database.
Rate this post
4 of 5 based on 4658 votesComments