im trying to send a name and email address from flash to an sql server, but i can't seem to get it working.
Heres the code.
import flash.events.Event;
stop();
submit.addEventListener(MouseEvent.CLICK, sendData);
function sendData(evt:MouseEvent){
//if(email.text!="" && nameval.text !=""){
var myData:URLRequest = new URLRequest("animation.php")
myData.method = URLRequestMethod.POST
var variables:URLVariables = new URLVariables()
variables.emailpost = "test";
// email.text
variables.namepost = "test";
//nameval.text
myData.data = variables
var loader:URLLoader = new URLLoader()
loader.dataFormat = URLLoaderDataFormat.TEXT
loader.load(myData)
play();
//}
}
And here's the PHP
<?php
//Capture data from $_POST array
$emailpost = $_POST['emailpost'];
$namepost= $_POST['namepost'];
//Connection to database
$connect = mysql_connect("server", "username", "password");
mysql_select_db ("dbname", $connect);
//Perform the query
$result = mysql_query("INSERT INTO dbname VALUES('$emailpost', '$namepost')");
mysql_close($connect);
?>
I've took most of this code from other websites so its cut and i'm not 100% sure whats missing from it to cause it to work.
Also does it matter that the database is on a different server to the php file and animation?