我需要使用 AS3 创建一个电子邮件表单。来自 AS2 我的知识是有限的。在舞台上,我有一个提交按钮、一个组合框和两个用于电子邮件和密码的文本输入字段。通读一些教程,我知道如何将变量电子邮件和密码发送到 mysql 数据库。我的问题是,我在表单中填充了一些数据的组合框。我怎样才能将那条数据发送到我的数据库?我向您展示了我的代码,抱歉它相当长,但如果您能提供帮助,那就太好了!
//Building the variables
var phpVars:URLVariables = new URLVariables();
//Requesting the php file
var phpFileRequest:URLRequest = new URLRequest("php.file");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
//Building the loader
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Variables ready for the processing
phpVars.email = email.text;
phpVars.password = password.text;
btn_one.addEventListener(MouseEvent.CLICK, btnHandler);
//Validate form fields
function btnHandler(event:MouseEvent):void{
statusTxt.text = "" + event.target.data.systemResult;
trace(event.target.data.systemResult);
}
var statusTxt:TextField = new TextField();
statusTxt.x = 160.00;
statusTxt.y = 9.80;
statusTxt.width = 241.95;
statusTxt.height = 22.75;
statusTxt.text = "Please fill out the form below";
addChild(statusTxt);
//Wanting to add this combobox to my db
var persons:Array = new Array();
persons[0] = "Male";
persons[1] = "Female";
combo_box.dataProvider = new DataProvider(persons);
combo_box.addEventListener(Event.CHANGE, dataHandler);
function dataHandler(e:Event):void{
trace(e.target.value);
}