
Eventually Flash cannot execute the function on MySQL directly, but through PHP (cmiiw). In order to to send variable to a MySQL database from actionscript, we’re gonna need to understand how PHP and MySQL work. I assume that you have knowledge about MySQL, so we just going deep down on Flash. OK, here we go…
First setup a database and name it “friend”, and fill it with this query:
CREATE TABLE IF NOT EXISTS `user` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `phone` varchar(50) NOT NULL, `email` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=72 ;
on actionscript:
lets create a MovieClip, say “form”,
var form:MovieClip = this.createEmptyMovieClip("form", this.getNextHighestDepth());
then, we declare the variable that we want to send by attaching it to previous MovieClip “form”. And also, we want to input that variable dynamically, so we assign it as equal as input text. It means that whatever we type on input text, would be the variable’s value.
form.name = name_txt.text; form.email = email_txt.text; form.phone = phone_txt.text;
next, we’re going to send that variable to PHP by using POST method.
form.loadVariables("input.php","POST");
form.onData = function(success:Boolean) {
for (var a in this) {
trace([a, this[a]]);
}
}
on input.php
<?php
mysql_connect("host", "user", "password") or die(mysql_error());
mysql_select_db("friend") or die(mysql_error());
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$sql_user = "INSERT INTO `friend`.`user` (`name`,`phone`,`email`)
VALUES ('$name', '$phone', '$email');";
$result_user = mysql_query($sql_user);
?>
Don’t forget to configure input.php, and it should be work. I think that’s all.


weeeshh… jago banget mas muda ini…
yeah.. gitu dong mud. gayaan lagi pake english, gak ngerti gue.
kok g ada file input.php nya…?
@ariawan & @deni hehehe… manstab kan gw
@deny_tb lagian blm jadi dah komen, dah nih hehe
Ada juga pecinta flash di negeri tercinta. Salam Flash bro
yoi donk hehehe, salam Flash juga bro