我为我的移动应用程序创建了一个登录系统,但按下按钮的那一刻没有任何反应。当我查看网络监视器时,它正在连接,所以我想知道出了什么问题。
我错过了什么吗?
.mxml 文件:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
currentState="login" tabBarVisible="{currentState!='login'}">
<s:actionContent>
<s:Button includeIn="login" label="login" click="currentState='planner'"/>
</s:actionContent>
<s:states>
<s:State name="login"/>
<s:State name="planner"/>
</s:states>
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private function checkLogin(evt:ResultEvent):void
{
if(login.lastResult.loginsuccess == "yes"){currentState = "planner";}
if(evt.result.loginsuccess == "yes")
{
currentState = "planner";
}
if(evt.result.loginsuccess == "no")
{
statusLabel.text = "Incorrect. (Try user/password)";
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="login" result="checkLogin(event)"
method="POST"
url="http://localhost:8888/MenuPlannerApp/Services/login.php"
useProxy="false">
<s:request xmlns="">
<username>{email.text}</username>
<password>{password.text}</password>
</s:request>
</s:HTTPService>
</fx:Declarations>
<s:BorderContainer includeIn="login" width="100%" height="100%" >
<s:Label id="statusLabel" />
<s:TextInput id="email" y="192" left="15" right="15" text="Email address"/>
<s:TextInput id="password" y="247" left="15" right="15" text="Password" displayAsPassword="true"/>
<s:Button id="submit" y="306" right="15" width="100" height="30"
label="Login" click="login.send();"/>
<s:Button id="LoginCreate" y="306" left="15" width="100" height="30"
label="Create"/>
<s:Label x="166" y="39" width="113" height="101" fontSize="30"
text="Menu
Planner"/>
</s:BorderContainer>
<s:BorderContainer includeIn="planner" width="100%" height="100%">
<s:HGroup y="10" width="320" height="46" horizontalAlign="center"
textAlign="center">
</s:HGroup>
<s:VGroup includeIn="planner" >
</s:VGroup>
</s:BorderContainer>
</s:View>
.php 文件
<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "xxxx" );
define( "DATABASE_PASSWORD", "xxxx" );
define( "DATABASE_NAME", "MenuPlannerApp" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
//asign the data passed from Flex to variables
$email = ($_GET["email"]);
$password = ($_GET["password"]);
//Query the database to see if the given username/password combination is valid.
$query = "SELECT * FROM account WHERE email = '$email' AND password = '$password'";
$result = $mysqli->query($query);
//start outputting the XML
$output = "<loginsuccess>";
//if the query returned true, the output <loginsuccess>yes</loginsuccess> else output <loginsuccess>no</loginsuccess>
if(!$result->num_rows)
{
$output .= "yes";
}else{
$output .= "no";
}
$output .= "</loginsuccess>";
//output all the XML
print ($output);
?>