HTTPService: call a php script passing parameters and receive a response from server
How to send an user name from Flex to the PHP file and receive its email address
(naturally you could make a query to the db to get these values)
(naturally you could make a query to the db to get these values)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="init(event)" >
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
private const NOME_UTENTE:String = "Fabio Biondi";
private function init(evt:FlexEvent):void
{
phpRPC.url="assets/Es02_CheckUser.php";
phpRPC.send({ utente: NOME_UTENTE} )
}
private function viewEmail():void
{
outputArea_txt.text = phpRPC.lastResult.email
}
]]>
</mx:Script>
<mx:HTTPService
id="phpRPC"
resultFormat="flashvars"
result="viewEmail()"
/>
<mx:TextArea
id="outputArea_txt" y="20"/>
</mx:Application>
// PHP CODE
<?php
switch($_REQUEST['utente'])
{
case "Fabio Biondi":
echo "email=info@fabiobiondi.com";
break;
default:
echo "email=User not found";
break;
}
?>




