Viper Creations
Comeback Contest
Check out our forums for the an explosive comeback contest. We are giving away everything from iPods to Visual Studio. more...
»User: »Password:   Remember Me? 
Webmaster Forum - Viper Creations / Programming / Adobe Flex / Adobe Flex Create a Login System with Flex and PHP Tutorial
Posted:  07 May 2007 09:01
Since completing the tutorial as shown i have set up an apache server to act as my local host for testing purposes. I have also created the database called 'flex' with a table called users with fields: username, password and loginsuccess.

I have put sample data into the database.

The database and login.php are sat on the server in the same location and my http service url is pointing at the server.

When i run the app i get the following error:

Error #1069: Property loginsuccess not found on String and there is no default value.

any ideas...please help, i am a complete noob to all of this and trying to make sense of it all...
Posted:  08 May 2007 20:48
Hi tom,

Welcome to Viper Creations

sorry for the late response!

loginsuccess should not be a field in the table.

it is what is output by the php script.

for example, the php script should output either
<loginsuccess>yes</loginsuccess> OR <loginsuccess>no</loginsuccess>

yes or no depending whether or not the login was successful obviously.

Here is the php code I used:
Code:

   1.
      <?php
   2.
      define( "DATABASE_SERVER", "localhost" );
   3.
      define( "DATABASE_USERNAME", "user" );
   4.
      define( "DATABASE_PASSWORD", "pass" );
   5.
      define( "DATABASE_NAME", "flex" );
   6.
      //connect to the database
   7.
      $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
   8.
      //select the database
   9.
      mysql_select_db( DATABASE_NAME );
  10.
      //asign the data passed from Flex to variables
  11.
      $username = mysql_real_escape_string($_POST["username"]);
  12.
      $password = mysql_real_escape_string($_POST["password"]);
  13.
      //Query the database to see if the given username/password combination is valid.
  14.
      $query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
  15.
      $result = mysql_fetch_array(mysql_query($query));
  16.
      //start outputting the XML
  17.
      $output = "<loginsuccess>";
  18.
      //if the query returned true, the output <loginsuccess>yes</loginsuccess> else output <loginsuccess>no</loginsuccess>
  19.
      if(!$result)
  20.
      {
  21.
      $output .= "no";           
  22.
      }else{
  23.
      $output .= "yes";     
  24.
      }
  25.
      $output .= "</loginsuccess>";
  26.
      //output all the XML
  27.
      print ($output);
  28.
      ?>




It's the same code as on the tutorial.

Does that help you out?
__________________
http://www.vipercreations.com/images/banner/result.gif
Posted:  13 May 2007 10:43
Hi Daniel thanks for you reply...it has helped my understanding of how to go about creating my own login flex app based on your tutorial.  like i said i am a newbie to all this and have spent the last 12 months using flex but primarily interface design...it is only now that i would like to know how to retrieve and connect to a data source of some kind.

due to my familiarity (but very limited) knowledge of MS Access i decided that the design of a simple dbase in access would be the best way to go...i was going in blind lol...it was this initial belief that led me to your website

initially i created a dbase called flex with the fields in it...(then corrected it by removing the loginsuccess field)

installed apache...
installed php...

created a file called login.php and wacked them both on the server...

i then pointed my http service to the localhost...

thinking that magically the php and the access dbase would talk...(see i wasnt kidding my knowledge of this kind of stuff really is very bad!!)

for the past week i have been reading around and have now discovered that i need to install mysql and the ODBC driver...

having installed them both and hit more troubles trying to export a table in access using the ODBC driver...

im still at a loss trying to see my way through this code like fog lol...

any advice or help would be appreciated during these difficult times lol...

thanks for all you help thus far.
Posted:  30 May 2007 02:58
Hi Daniel, just to let you know i sorted it out and got it working
Posted:  30 May 2007 10:25
Great!

Maybe you would like to tell us how you solved the problem? In case anybody else has that problem?
__________________
http://www.vipercreations.com/images/banner/result.gif
Posted:  09 Mar 2008 22:32
ok, I hate to keep beating a dead horse, but I'm getting really frustrated.
I've followed the login system tutorial and everything is working great.
I set up a DB that has the username and password stuff that the php file looks for, and when I change the url in the flex code to my url I get the error:

[RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:216]
    at mx.rpc::Responder/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:49]
    at mx.rpc::AsyncRequest/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
    at DirectHTTPMessageResponder/securityErrorHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:368]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/redirectEvent()

Any help on this one will be very much appreciated.
Thanks.
Posted:  26 Jul 2008 04:59
Todaynic Awarded HK Domain Golden Service PartnerOn Jan 25,2008, Hong Kong Internet Registration Corporation Limited (HKIRC) and its wholly-owned subsidiary, Hong Kong Domain Name Registration Company ...
www.todaynic.com
Posted:  19 Sep 2008 12:16
Great tutorial, I have it implemented, and working fine. But I am curious as to how you would pass a userid variable from one state to another. Like in straight PHP you can set a SESSION_ID which will allow you pass a few variables from page to page.

I would like to pull to a datagrid/mysql on the "Logged In" state, that is assosciated with the user

ie: SELECT * FROM users WHERE userid = $_POST['userid'];

or something similar. I am at a loss as to how to pass this variable from the base state to the logged in state.


HELP!!!!!!
Posted:  05 Nov 2008 21:53
Hello there I have recently done this tutorial and it is working correctly when I direct it to the php on your server and when i upload it to my university webspace but when i try to direct it to use the php file on my apache server it gives me the "security error accessing url" error, which i have discovered is a flash player error and can be fixed by having both php and swf file on same server.

Anyway when I place both the files on my apache server and click the submit button nothing happens. It doesn't come up with the busy icon or tell me theres an error or anything.

Could someone please help me figure out what is wrong.

Bryan
Posted:  28 Dec 2008 02:02
Hi daniel, i got some problem with the php script.. apache crashed when i redirect your code to my server, i mean the only thing i replace is that line where it said: http://www.vipercreations.com/site_admin/login.php

to mine line in localhost..

what do you think about it?
Posted:  06 May 2009 06:37
HI to all members of the forum,
I hope you are well!
I am a beginner in the development Flex / PHP / MYSQL
I have a question concerning the draft LOGIN SYSTEM, for authentication, I import from the link and it works.

what I want is to make it work locally, not to connect to your site from the address: http://www.vipercreations.com/site_admin/login.php

what I want is to connect to database for users and files: XML and PHP or other ... it depends: for local authentication
if you have the php file and XML, and their location on the flex project please contact me if you like
in anticipation of a favorable response that I hope, accept my respect.
                          thank you in advance!
          Wissam
Posted:  18 Aug 2009 04:14
You can find samplewas prepared from this link
code is written in the following

You can ask any question you flex?

Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="390" height="225"   backgroundGradientColors="[#252525, #454444]"     creationComplete="xmlservir.send()" >
   
        <mx:Style>
           
            .lbtnLink{
               
                icon: Embed("../img/link.png";
            }
            .lbtnProfil{
               
                icon: Embed("../img/profil.png";
            }
           
           
           
        </mx:Style>
   
        <mx:Script>
            <![CDATA[
                import mx.effects.easing.*;;
                import mx.binding.utils.BindingUtils;
               
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
               
                [Bindable]
                private var xmldata_:ArrayCollection;
               
               
               
                private function gelenData(event:ResultEvent):void{
                    xmldata_ = event.result.nakliyeciler.nakliye;
                    xcombo.dataProvider = xmldata_;
                    xcombo.labelField = "il";
                    //xcombo.dataField = "il";
                   
                   
                    //xmldata_2 = event.result.nakliyeciler.nakliye.firm;
                   
                    xgrid.dataProvider = xcombo.selectedItem.firms;
                    //tel_1.text = xgrid.itemRenderer("0".tel1;
                    xgrid.selectedIndex = 0;
                    tel_1.text = xgrid.selectedItem.tel1;
                    tel_2.text = xgrid.selectedItem.tel2;
                    tel_3.text = xgrid.selectedItem.tel3;
                    tel_4.text = xgrid.selectedItem.tel4;
                    res_.source = "../img/" + xgrid.selectedItem.res;
                    wipeLeft.play();
                    
           
                }
                private function a_data():void{
                   
                   
                    xgrid.dataProvider = xcombo.selectedItem.firms;
                   
                   
           
                }
               
                private function a_data_grid():void{
                   
                   
                    tel_1.text = xgrid.selectedItem.tel1;
                    tel_2.text = xgrid.selectedItem.tel2;
                    tel_3.text = xgrid.selectedItem.tel3;
                    tel_4.text = xgrid.selectedItem.tel4;
                    res_.source = "../img/" + xgrid.selectedItem.res;
                    wipeLeft.play();
                   
           
                }
               
                private function profile_git():void{
                   
                    var url:String = "profil.aspx?id=" + xgrid.selectedItem.sno_;
                  
                    var req:URLRequest = new URLRequest(url);
                    navigateToURL(req, '_top';
                    

                }
               
                private function siteye_git():void{
                   
                    var url:String =  xgrid.selectedItem.web_;
                  
                    var req:URLRequest = new URLRequest(url);
                    navigateToURL(req, '_blank';
                    

                }
               
               
            ]]>
        </mx:Script>   
       
       
         <mx:HTTPService url="http://localhost:2673/portal_25/filtre.aspx"
    id="xmlservir" result="gelenData(event)"  />
   
    <mx:WipeLeft id="wipeLeft"
            target="{res_}"
            moveEasingFunction="Elastic.easeOut"
            duration="5000" />
   
    <mx:ComboBox id="xcombo" x="10" y="47" width="158"
        openDuration="1000"
        closeDuration="500" change="a_data()"></mx:ComboBox>
    <mxataGrid id="xgrid" x="10" y="77" width="161" height="138"  change="{a_data_grid()}">
    <mx:columns>
        <mxataGridColumn
            dataField="firm"
            headerText="Nakliyat Firmaları"
            editable="false" />
    </mx:columns>
   
    </mxataGrid>
    <mx:Image x="0" y="-1" source="../img/nf.jpg"/>
    <mx:Image x="179" y="47" width="201" height="95" id="res_" />
    <mx:Label x="179" y="150" text="Label" width="99" color="#FFFFFF" textAlign="left" id="tel_1"/>
    <mx:Label x="286" y="150" text="Label" width="96" color="#FFFFFF" id="tel_3"/>
    <mx:Label x="179" y="171" text="Label" color="#FFFFFF" textAlign="left" width="99" id="tel_2"/>
    <mx:Label x="286" y="171" text="Label" color="#FFFFFF" textAlign="left" width="99" id="tel_4"/>
    <mx:Button x="179" y="193" label="Profil" width="89" color="#000000" borderColor="#000000"  fillColors="[#FDCD0C, #E2B607]" themeColor="#FFEA00" alpha="1.0" id="p_" click="{profile_git()}"  fontStyle="italic" styleName="lbtnProfil" fontSize="8" fontFamily="Verdana" fillAlphas="[1.0, 1.0]"/>
    <mx:Button x="271" y="193" label="Web Sayfası" width="109" color="#000000" borderColor="#000000"  fillColors="[#FDCD0C, #E2B607]" themeColor="#FFEA00" alpha="1.0" click="{siteye_git()}" styleName="lbtnLink"  fontSize="8" fontFamily="Verdana" fillAlphas="[1.0, 1.0]"/>
   
   
   
</mx:Application>



team
evden eve nakliyat
evden eve nakliyat tv
Posted:  27 Apr 2010 12:39
I have a similar question I am trying to get a login page to work with a different provider so I tried very simply to modify the PHP code to just return yes. But I keep getting the following error.

Error #1069: Property loginsuccess not found on String and there is no default value.

My PHP code looks like this....
<?php
$output .= "<loginsuccess>yes</loginsuccess>"
print ($output)
?>

It will not however return the loginsuccess tag in Flex.

I have never used PHP before so is there something wrong in the PHP code?
Posted:  28 Jun 2010 05:55
New era caps story: www.caps-hot.com  Wholesale new era caps on caps-hot.com New Era Birmingham will feature the widest selection of New Era headwear in the world. A mixture of designs will adorn the company’s signature fitted baseball cap, cheap 59FIFTY caps, wholesale new era caps,as well as over 250 adjustable cap styles, hats from the EK by New Era brand, and the latest Authentic Collection in the new performance fabric material. Additionally, there will be product from the Marvel license including future collections of the Fantastic 4 series, Wolverine and Captain America as well as the DC Comics license featuring original comic book artwork in the Batman and Superman collections. Wholesale 59FIFTY hats.
The new store has a similar design to the flagship stores in London and New York, with exposed brickwork, custom made maple cabinetry, and floor inlays of the company’s logo and framed visor sticker found on the wholesale New Era 59FIFTY caps. In Spring 2009 the space is across one level and will display all of New Era’s latest design exclusives and showcase New Era’s Apparel collection launching .and we will update all new style for wholesale new era caps.also we have other brand caps, like wholesale red bull caps.
And need others brand help please contact us: capshot@live.cn
__________________
New era caps story: www.caps-hot.com  Wholesale new era caps on caps-hot.com
And need others brand help please contact us: capshot@live.cn
Posted:  28 Jun 2010 05:55
New era caps story: www.caps-hot.com  Wholesale new era caps on caps-hot.com New Era Birmingham will feature the widest selection of New Era headwear in the world. A mixture of designs will adorn the company’s signature fitted baseball cap, cheap 59FIFTY caps, wholesale new era caps,as well as over 250 adjustable cap styles, hats from the EK by New Era brand, and the latest Authentic Collection in the new performance fabric material. Additionally, there will be product from the Marvel license including future collections of the Fantastic 4 series, Wolverine and Captain America as well as the DC Comics license featuring original comic book artwork in the Batman and Superman collections. Wholesale 59FIFTY hats.
The new store has a similar design to the flagship stores in London and New York, with exposed brickwork, custom made maple cabinetry, and floor inlays of the company’s logo and framed visor sticker found on the wholesale New Era 59FIFTY caps. In Spring 2009 the space is across one level and will display all of New Era’s latest design exclusives and showcase New Era’s Apparel collection launching .and we will update all new style for wholesale new era caps.also we have other brand caps, like wholesale red bull caps.
And need others brand help please contact us: capshot@live.cn
__________________
New era caps story: www.caps-hot.com  Wholesale new era caps on caps-hot.com
And need others brand help please contact us: capshot@live.cn