gpt4 book ai didi

php - 使用 Flex 移动设备登录系统

转载 作者:行者123 更新时间:2023-11-29 14:35:51 24 4
gpt4 key购买 nike

我遵循了一个关于如何在 Flex 中制作登录系统的示例。此示例不是为 Flex 移动项目制作的,而是为在浏览器中运行的桌面制作的。据我了解,我可以使用相同的代码但具有不同的组件。我不断收到错误。我的代码在下面。

连接和查询数据库的PHP代码,并用xml返回结果

<?php

echo "<?xml version="\"1.0\" ?>\n";

$con = mysql_connect("HOST","USER","PASS");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("DatabaseName here");

//Variables that I wil retrieve from the flex application

$user = $_POST['user'];
$pass = $_POST['pass'];


//mySQL query
$result = mysql_query("SELECT * FROM `brukere` WHERE 1");

//not logged in so it's false
$loged = false;

//Comparing the text i retrieved from the flex app and the rows in my database.

while($row = mysql_fetch_assoc($result))
{
if(strtolower($user) == strtolower($row['brukernavn']) &&
strtolower($pass) == strtolower($row['passord']))
{
$loged = true:
}
}

//so if loged is true, pass true in xml to my flex application.
if($loged == true)
echo "<status>true</status>";
else
echo "<status>false</status>";
?>

Flex 代码中的我的 HTTPService

    <fx:Declarations>

<mx:HTTPService id="loginService" result="onResult(event)" method="POST" url="URL TO THE PHP SCRIPT">

<mx:request xmlns="">

<user>{username.text}</user>

<pass>{pass.text}</pass>

</mx:request>

</mx:HTTPService>
</fx:Declarations>

然后是我的 ActionScript

<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;

private function login():void
{
loginService.send();
}

private function onResult(e:ResultEvent):void
{

if(e.result.status == true) {

Alert.show("Succesful");

}

else {

Alert.show("Wrong");
}
}
]]>
</fx:Script>

最后是图形用户界面:

<s:VGroup includeIn="notLoggedIn" x="286" y="164" width="45%" height="200">
<s:HGroup includeIn="notLoggedIn" width="100%" height="38" verticalAlign="middle">
<s:Label width="30%" height="31" text="Brukernavn: " verticalAlign="middle"/>
<s:TextInput id="username" width="70%"/>
</s:HGroup>
<s:Spacer width="459" height="10"/>
<s:HGroup includeIn="notLoggedIn" width="100%" height="40" verticalAlign="middle">
<s:Label width="30%" height="34" text="Passord:" verticalAlign="middle"/>
<s:TextInput id="pass" width="70%"/>
</s:HGroup>
<s:Spacer width="458" height="10"/>
<s:HGroup width="462" height="65">
<s:Spacer width="70%" height="64"/>
<s:Button width="30%" label="Logg inn" click="login()"/>
</s:HGroup>
</s:VGroup>

这是我调试应用程序时的所有输出:

[SWF] AKTIVe.swf - 4,192,242 bytes after decompression
ReferenceError: Error #1069: Property status not found on String and there is no default value.
at Views::Login/onResult()[C:\Users\Tobias\Documents\bacheloroppgave\workspace\src\Views\Login.mxml:54]
at Views::Login/__loginService_result()[C:\Users\Tobias\Documents\bacheloroppgave\workspace\src\Views\Login.mxml:13]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:993]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:451]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

我的第一个想法是我不能使用 <mx:HTTPService>以及我的移动 Flex 应用程序中的其他基于 mx 的服务。有人知道我应该寻找什么吗?

很抱歉这篇文章很长,但至少它足够非正式:)

提前致谢

最佳答案

使用 charles 代理检查您到底发送到服务器(请求)并从服务器返回(响应)的内容

charles proxy website

关于php - 使用 Flex 移动设备登录系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9064704/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com