Ask a Question related to Macromedia Flash Data Integration, Design and Development.
-
Mwalimo #1
Flash CS3 <-->PHP<-->MySQL (Almost there!)
I am working on the Flash CS3/PHP/MySQL integration and I think I am almost
there.
Below is the script in my .fla. This script is calling the register.php
script to pass the variables reg_user (String), reg_pass(String), reg_mail
(String) and sql_type (Integer).
In register.php, I am displaying the results of the DB action and it's showing
&n=0&
The php script is working fine. I have tested by direct placement and value
assignment ( $reg_user="Tsitsi",
$reg_pass="password",$reg_mail="tsitsi@els.co.za" and $sql_type=1) in the php
script.
So what is wrong with the script below? It seems to be failing to 'transmit'
the values over to the php script?
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLVariables;
var u:String="Tsitsi"
var p:String="password"
var e:String="tsitsi@els.co.zw"
var t:int=1
var variables:URLVariables = new URLVariables();
variables.reg_user=u
variables.reg_pass=p
variables.reg_mail=e
variables.sql_type=t
trace(variables)
var url:String = "http://localhost:81/flash/register.php";
var request:URLRequest = new URLRequest(url);
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request);
Mwalimo Guest
-
flash/php/mysql
Hi, so I've created an html/php questionnaire that sends user entered information to a mysql database. After people submit their information I'd... -
Export Querries from Flash 8 to MySQL and Import Datafrom MySQL
Hi friends, I am making a web site for a customer and i need to import data from MySQL Database but i don't know how to do it. I would appreciate... -
PHP / MySQL / Flash 8
I've created a simple MySQL Database, query via PHP and then load in the vars via LoadVars ( in Flash ). Everything seems ok. But when I see the... -
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
When i try to start my mysql server, i get this error ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'... -
flash + php + mysql
i have a blog which currently uses php + mysql only and i wanted to integrate the data into flash,this is what i did in the php version of my blog(... -
Noelbaland #2
Re: Flash CS3 <-->PHP<-->MySQL (Almost there!)
Hello there,
I think the problem is in how you're capturing the variables in your PHP
script. I created an example using your Actionscript code and it works fine.
Instead of hard coding the values for the variables in the script, I created a
registration form and got the values from input textfields. Once you hit the
SUBMIT button a window opens in the browser and a PHP file catches all the
submitted data and outputs the results.
Below is the code I used in both Flash and PHP files. You can view the
example here and download the files here.
Hope that helps!
[ACTIONSCRIPT]
import flash.net.*;
submit_btn.addEventListener(MouseEvent.CLICK, submitForm);
reset_btn.addEventListener(MouseEvent.CLICK, resetForm);
function submitForm(event:MouseEvent):void
{
var u:String = user_txt.text;
var p:String = pass_txt.text;
var e:String = email_txt.text;
var t:int = 1;
var variables:URLVariables = new URLVariables();
variables.reg_user = u;
variables.reg_pass = p;
variables.reg_mail = e;
variables.sql_type = t;
var url:String = "http://localhost/FLASH/register.php";
var request:URLRequest = new URLRequest(url);
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request);
}
function resetForm(event:MouseEvent):void
{
user_txt.text = "";
pass_txt.text = "";
email_txt.text = "";
}
[PHP]
<?php
echo "This is the array result that is returned from the Flash form<br><br>";
foreach($_POST as $key=>$val)
{
echo "$key = $val <br>";
}
echo
"<br>----------------------------------------------------------------------<br><
br>";
echo "Registration results: ";
if(isset($_POST['reg_pass']))
{
$pass = $_POST['reg_pass'];
$user = $_POST['reg_user'];
$email = $_POST['reg_mail'];
if($pass == "" || $user == "" || $email == "")
{
echo "Please fill in all fields! <br>";
} else {
// Insert details into database
echo "Thank you <strong>$user</strong>, you have been registered!
<br>";
}
}
?>
Noelbaland Guest
-



Reply With Quote

