douqujin2767 2012-11-02 03:48
浏览 57
已采纳

Flex Builder PHP登录

I created a login system for my mobile application, but the moment I press the button nothing happens . When I look at the network monitor, it is connecting, so I am wondering what is going wrong.

Am I missing something?

mxml file:

<?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&#xd;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 file

<?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);

?>
  • 写回答

1条回答 默认 最新

  • douyu4535 2012-11-02 04:01
    关注

    You are using mysqli to connect to the database but calling the obsolete mysql_## functions to execute the query.

    Instead update your code with

    $query = "SELECT * FROM account WHERE email = '$username' AND password = '$password'";
    $result = $mysqli->query($query);
    if(!$result->num_rows)
    // No Results Found
    else
    // Results found
    

    For more functions See : MYSQLI PHP Manual

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效