var loader:URLLoader = new URLLoader(); var url:URLRequest = new URLRequest("test.asp"); url.method = URLRequestMethod.POST; var values:URLVariables = new URLVariables(); values.message="hello im flash!"; url.data = values; loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(Event.COMPLETE,loaded); function loaded(e:Event) { out1.text=loader.data; //outPut: phpMessage=im php message!&flashMessage=hello im flash! out2.text=loader.data.phpMessage; // im php message! out3.text=loader.data.flashMessage; // hello im flash! out4.text=loader.data.dbMessage; } loader.load(url); |
<%@LANGUAGE="JAVASCRIPT"%> <% //接收flash传进来的数据 var flashData; flashData = Request("message"); //发给flash的数据 var aspMessage; aspMessage = ’im asp message!’; //数据库的相关操作 //====================================== var conn; var rs; var sql; var strPath; strPath="test.mdb"; try{ conn = Server.CreateObject("ADODB.Connection"); conn.connectionString = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(strPath); conn.open(); }catch(e){ Response.Write(’<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><div style="font-size:12px;font-weight:bold;border:1px solid #006;padding:6px;background:#fcc">数据库连接出错,请检查连接字串!</div>’); Response.End } rs=Server.createobject("ADODB.Recordset") ; sql="select * from name" ; rs.open(sql,conn,1,1); //====================================== Response.Write("phpMessage="+aspMessage+"&"+ "flashMessage="+flashData+"&"+"dbMessage="+rs("companyname")); %> |
var loader:URLLoader = new URLLoader(); var url:URLRequest = new URLRequest("test.php"); url.method = URLRequestMethod.POST; var values:URLVariables = new URLVariables(); values.message="hello im flash!"; url.data = values; loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(Event.COMPLETE,loaded); function loaded(e:Event) { out1.text=loader.data; //outPut: phpMessage=im php message!&flashMessage=hello im flash! out2.text=loader.data.phpMessage; // im php message! out3.text=loader.data.flashMessage; // hello im flash! out4.text=loader.data.dbMessage; } loader.load(url); |
<?php
//这里都是有关数据库的操作 //=================================== Define(’DATABASE_SERVER’, ’localhost’); Define(’DATABASE_USERNAME’, ’root’); Define(’DATABASE_PASSWORD’, ’root’); Define(’DATABASE_NAME’, ’flextest’); $link=@mysql_connect(DATABASE_SERVER,DATABASE_USERNAME,DATABASE_PASSWORD); @mysql_select_db(DATABASE_NAME,$link); $result=@mysql_query("Select * from users"); $user=@mysql_fetch_array($result,MYSQL_ASSOC); //echo $user[’userid’]; $dbvar=$user[’userid’]; //=================================== //接收flash传进来的数据 $flashData = $_POST[’message’]; //给flash发送的数据 $phpMessage = ’im php message!’; echo "phpMessage=$phpMessage&flashMessage=$flashData&dbMessage=$dbvar"; ?> |
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onInit()" xmlns="*" layout="absolute" backgroundGradientColors="[#ffffff, #c0c0c0]"> <mx:Script> <![CDATA[ public function onInit():void { userRequest.send(); } ]]> </mx:Script> <mx:HTTPService id="userRequest" url="request.php" useProxy="false" method="POST"> <mx:request xmlns=""> <username>{username.text}</username><emailaddress>{emailaddress.text}</emailaddress> </mx:request> </mx:HTTPService> <mx:Form x="22" y="10" width="356"> <mx:HBox> <mx:Label text="Username"/> <mx:TextInput id="username"/> </mx:HBox> <mx:HBox> <mx:Label text="Email Address"/> <mx:TextInput id="emailaddress"/> </mx:HBox> <mx:Button label="Submit" click="userRequest.send()"/> </mx:Form> <mx:DataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.lastResult.users.user}"> <mx:columns> <mx:DataGridColumn headerText="User ID" dataField="userid"/> <mx:DataGridColumn headerText="User Name" dataField="username"/> </mx:columns> </mx:DataGrid> <mx:TextInput x="22" y="292" id="selectedemailaddress" text="{dgUserRequest.selectedItem.emailaddress}"/> </mx:Application> |
<?php
/* Thanks to Pete Mackie for the code below */ Define(’DATABASE_SERVER’, ’localhost’); Define(’DATABASE_USERNAME’, ’root’); Define(’DATABASE_PASSWORD’, ’root’); Define(’DATABASE_NAME’, ’flextest’); # Connect to the database $mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME); # Check connection if (mysqli_connect_errno()) { printf("MySQL connect failed: %s\n", mysqli_connect_error()); exit(); } # Quote variable to make safe function quote_smart($value) { global $mysqli; # Stripslashes if (get_magic_quotes_gpc()) $value = stripslashes($value); # Quote if not integer if (!is_numeric($value)) $value = $mysqli->real_escape_string($value); return $value; } if (!empty($_POST) && $_SERVER[’REQUEST_METHOD’] == ’POST’) { if ($_POST[’emailaddress’] && $_POST[’username’]) { # Add the user $query = sprintf("Insert INTO users VALUES (’’, ’%s’, ’%s’)", quote_smart($_POST[’username’]), quote_smart($_POST[’emailaddress’])); if (!@$mysqli->query($query)) { printf("’flextest’ user database query insert error: %s\n", $mysqli->error); $mysqli->close(); exit(); } } } # Return a list of all the users if (!$result=@$mysqli->query("Select * from users")) { printf("’flextest’ user database query select error: %s\n", $mysqli->error); $mysqli->close(); exit(); } $xml_return = "<users>"; while ($user = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $xml_return .= "<user><userid>".$user[’userid’]."</userid><username>".$user[’username’]."</username><emailaddress>".$user[’emailaddress’]."</emailaddress></user>\n"; } $xml_return.= "</users>"; $mysqli->close(); echo $xml_return; ?> |
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |