Log in form, working just need to expand.

Hello all,
I have built a flex log in screen, but need to expand it a bit.
At the moment it takes the values from the form (username and password) and looks in a database if those values are their and returns either true or false,  flex then looks at this value and either directs you to a new state or brings an error.
This is all fine,  btu in my database i have added an extra field "level"  so now i have "username" "password" "level"
basically depending on what level you are i want you to see a different state.
Here is my code so far.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" width="1024" height="768">
    <s:states>
        <s:State name="State1"/>
        <s:State name="Logged"/>
    </s:states>
    <fx:Declarations>
        <mx:HTTPService id="loginService" url="login.php" method="POST" result="loginResult(event)">
            <mx:request xmlns="">
                <user>{username}</user>
                <pass>{password}</pass>
            </mx:request>
        </mx:HTTPService>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.rpc.events.ResultEvent;
            import mx.controls.Alert;
            [Bindable] public var username:String;
            [Bindable] public var password:String;
            private function tryLogin():void
                username = usernameLogin.text;
                password = passwordLogin.text;
                usernameLogin.text = "";
                passwordLogin.text = "";
                loginService.send();
            private function loginResult(evt:ResultEvent):void
                if (evt.result.status == true)
                    currentState='Logged';   
                else
                    Alert.show("Login failedl", "Failure");
        ]]>
    </fx:Script>
    <fx:Style source="style.css" />
    <s:Panel x="387" y="242" width="250" height="146" title="Log in" dropShadowVisible="true" borderVisible="true" includeIn="State1">
        <s:Label x="10" y="25" text="Username:" fontFamily="Arial" fontSize="13"/>
        <s:Label x="10" y="55" text="Password:" fontFamily="Arial" fontSize="13"/>
        <s:TextInput x="85" y="20" width="153" restrict="a-z0-9A-Z" fontFamily="Arial" fontSize="13" fontWeight="bold" id="usernameLogin"/>
        <s:TextInput x="85" y="50" width="153" restrict="a-z0-9A-Z" displayAsPassword="true" fontFamily="Arial" fontSize="13" fontWeight="bold" id="passwordLogin"/>
        <s:Button x="168" y="81" label="Login" click="tryLogin()"/>
    </s:Panel>
    <s:Label includeIn="Logged" x="101" y="134" text="Welcome"/>
</s:Application>
and my php script
<?php
$hostname_conn = "localhost";
    $username_conn = "";
    $password_conn = "";
    $conn = mysql_connect($hostname_conn, $username_conn, $password_conn);
    mysql_select_db("videochat");
    //mysql_real_escape_string POST'ed data for security purposes
    $user = mysql_real_escape_string($_POST["user"]);
    $pass = mysql_real_escape_string($_POST["pass"]);
    //a little more security
    $code_entities_match = array('--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','> ','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
    $user = str_replace($code_entities_match, "", $user);
    $pass = str_replace($code_entities_match, "", $pass);
    $query = "SELECT * FROM usernames WHERE username = '$user' AND password = '$pass'";
    $result = mysql_query($query);
    $logged = mysql_num_rows($result);
    if ($logged == 1)
        echo "<status>true</status>";
    else
        echo "<status>false</status>";
    ?>
Now i know i need to epxnad both, so that the php returns their level, but i am getting a bit stuck, any help ?
Thanks

hi,
this is an example using zend services
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:valueObjects="valueObjects.*" xmlns:usersservice="services.usersservice.*">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
protected function button_clickHandler(event:MouseEvent):void
checkUserResult.token = usersService.checkUser(email.text,password.text);
protected function checkUserResult_resultHandler(event:ResultEvent):void
if (checkUserResult.lastResult != null)
currentState="success" ;
ti.text="welcome back, "+ event.result.UserName;
else
currentState="fail";
protected function button1_clickHandler(event:MouseEvent):void
currentState="State1";
]]>
</fx:Script>
<s:states>
<s:State name="State1"/>
<s:State name="success"/>
<s:State name="fail"/>
</s:states>
<fx:Declarations>
<valueObjects:Users id="users"/>
<usersservice:UsersService id="usersService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="checkUserResult" result="checkUserResult_resultHandler(event)"/>
</fx:Declarations>
<s:Panel width="350" horizontalCenter="0" verticalCenter="0" title="User Authentification" includeIn="State1">
<mx:Form defaultButton="{login_btn}" verticalGap="10" width="100%">
<mx:FormItem label="Email">
<s:TextInput id="email" width="240"/>
</mx:FormItem>
<mx:FormItem label="Password">
<s:TextInput id="password" width="121"/>
</mx:FormItem>
<s:HGroup width="100%" paddingTop="2" paddingLeft="2" paddingBottom="2" paddingRight="2">
<s:Button label="login" id="login_btn" click="button_clickHandler(event)" width="100"/>
<mx:Spacer width="100%"/>
<s:Button label="cancel" id="cancel_btn" click="button_clickHandler(event)" width="100"/>
</s:HGroup>
</mx:Form>
</s:Panel>
<s:Button includeIn="fail" y="291" label="Go Back" horizontalCenter="0" click="button1_clickHandler(event)"/>
<s:Label includeIn="fail" y="239" text="No Such User" horizontalCenter="0" fontSize="24" textAlign="center" color="#B11C1C" fontWeight="bold"/>
<s:TextArea includeIn="success" x="500" y="147" id="ti"/>
</s:Application>
php:
public function checkUser($email,$pass) {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where EMail=? and Password=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'ss', $email, $pass);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_bind_result($stmt, $row->ID, $row->Level, $row->UserName, $row->EMail, $row->Password);
if(mysqli_stmt_fetch($stmt)) {
      return $row;
} else {
      return null;
David.

Similar Messages

  • I've got a PHP form working, but need to add "autoRespond", anyone know?

    i've developed a working PHP5 file to submit the form to the
    webmaster (info@). Now, the client wants me to add on a custom
    autoResponder. basically, the user fills out the form, the user
    gets an e-mail saying thank you in the subject line and body copy,
    says it came from info@ website.
    Here's the PHP script that's linked to it:

    I take the simple (though not free) way:
    www.bebosoft.com/formstogo/
    domerdel wrote:
    > i've developed a working PHP5 file to submit the form to
    the
    > webmaster (info@). Now, the client wants me to add on a
    custom
    > autoResponder. basically, the user fills out the form,
    the user gets
    > an e-mail saying thank you in the subject line and body
    copy, says it
    > came from info@ website.
    >
    > Here's the PHP script that's linked to it:
    >
    >
    >
    > <?
    > error_reporting(1);
    > if ( $_POST['tpl'] == "mail_req.tpl" )
    > $mailto = Array("[email protected]");
    > else
    > $mailto = Array("[email protected]","[email protected]");
    >
    > $subject="Celibre Web Inquiry: {$_POST['name']}";
    >
    > if ( $_POST['tpl'] == "mail_req.tpl" ) {
    > $t_data=file_get_contents("mail_req.tpl");
    > $subject="Req Cert Inquiry from Website";
    > }
    > elseif ( $_POST['tpl'] )
    > $t_data=file_get_contents("mail_contact.tpl");
    > else
    > $t_data = file_get_contents("mail_template.tpl");
    > foreach($_POST as $key=>$value)
    > $t_data=str_replace("[".$key."]",$value,$t_data);
    >
    > if ( $_POST['companyname'] )
    > $fromname=$_POST['companyname'];
    > elseif ( $_POST['name'] )
    > $fromname = $_POST['name'];
    > else
    > $fromname = $_POST['firstName'] . " " .
    $_POST['lastName'];
    >
    > $headers = "MIME-Version: 1.0\n".
    > "Content-type: text/html; charset=iso-8859-1\n".
    > "From: \"Website.com\" <[email protected]>\n".
    > "Date: ".date("r")."\n";
    >
    > foreach($mailto as $value) {
    >
    mail($value,$subject,$t_data,str_replace("[to]",$value,$headers));
    > }
    >
    > header("location: thank_you.html");

  • My Ipad min will not power up or start after being on the charger this morning.  Was working just need to be charged no nothing.

    My Ipad min was working fine this morning when I noticed it need to be charged along with my Iphone.  Put them both on chargers.  Now Ipad min will not power or come out of sleep mode.  tried pushing home botton and the sleep/awake button on the to right to no avail.  Any Ideas what to try next?
    Thanks
    Tom

    Standard troubleshooting...
    1. Try a Restart by pressing the sleep/lock button until you see the slider.  Slide to power off.  Restart by pressing the sleep/lock button until you see the Apple logo.
    2. Try a Reset by pressing the home and sleep buttons until you see the Apple logo, ignoring the slider if, it comes up. Takes about 5-15 secs of button holding and you won't lose any data or settings.
    3. Remove all apps from Recently Used list...
    - From any Home Screen, double tap the home button to bring up the Recents List
    - Tap and hold any icon in this list until they wiggle
    - Press the red (-) to delete all apps from this list.
    - Press the home button twice when done.
    4. If still a problem restore with your backup.
    5. If still a problem restore as new, i.e. without your backup. See how it runs with nothing synced to it.
    6. If still a problem, it's likely a hardware issue.

  • I have a Win7Pro SP1 PC locked down with a Group Policy as it is a public facing PC. PDF fillable forms cannot be completed when logged on as the restricted user. The forms work as a normal user. What are the user requirements/permissions needed to fill f

    I have a Win7Pro SP1 PC locked down with a Group Policy as it is a public facing PC. PDF fillable forms cannot be completed when logged on as the restricted user. The forms work as a normal user. What are the user requirements/permissions needed to fill forms?

    Well, try this (I was able to fix my with these steps):
    Go Utilities > Disk Utility
    Select your Startup Disk, e.g. Macintosh HD
    Then, under the First Aid Tab, click Verify Disk Permissions.
    If there are errors, then click repair Disk Permissions.
    After it is done, restart the computer and see if your problem is resolved.
    I hope this help.
    Zeke
    www.ZekeYuen.com/blog/

  • I just need to know how you get an iTunes library off the original hard drive of a mac and onto an external hard drive and still have it work normally?

    I just need to know how you get an iTunes library off the original hard drive of an imac and onto an external hard drive and still have it work as it normally would?

    http://support.apple.com/kb/HT1449

  • I have ad Apple ID on my iPad , when I use the apple on my iPhone for the first time, I put in my Apple ID for the iPad, didn't work. Need to create a new one. Why? How can I just use my iPad ID on my iPhone?

    I have ad Apple ID on my iPad , when I use the apple on my iPhone for the first time, I put in my Apple ID for the iPad, didn't work. Need to create a new one. Why? How can I just use my iPad ID on my iPhone?

    Hi kamfong,
    Went to Settings where?
    If you want to use your exisiting Apple ID on your iPad, you need to:
    1.     Go to Settings>iTunes & App Store and sign out the new ID, and then sign on the old one
    2.     Go to Settings>iCloud, scroll to the bottom and delete the iCloud account, and the sign back onto iCloud using the old ID
    You still have not indindated why you are saying that using your old ID originally "didn't work". What do you mean by that? Did you get some sort of error when you tried to sign on with your exisiting Apple ID?
    Cheers,
    GB

  • HT4865 I just bought this ipad and cannot log out from icloud because i dont have the password.how can i log out from icloud?need help

    I just bought this ipad and cannot log out from icloud because i dont have the password.how can i log out from icloud?need help

    You need to return it to the seller and get your money back.  You cannot reset or use the device with another AppleID installed unless you know the password for that ID.
    If the device has been jailbroken, no one on here can give you any further help...the Terms of Use prohibit us from doing so.

  • Hi, just need to know how to get my music, video, pictures and apps form my iPhone to my new laptop as the old computer, which I used before was stolen. I only have my phone left and if I try to conect it to my new laptop it's trying to delete everything.

    Hi, just need to know how to get my music, video, pictures and apps form my iPhone to my new laptop as the old computer, which I used before was stolen. I only have my phone left and if I try to conect it to my new laptop it's trying to delete everything.

    I have also noticed all my settings won't stay set, example....I removed the check mark from "third party cookies", the when I close Firefox and reopen the check mark is back, also my tool bar has screwed up....can't reset, been having trouble the up grade.

  • My airport extreme is flashing amber it says i need a ip address .... it was working just fine yesterday until i had to reboot cable modem how do i get my extreme to work again so i can have wireless

    my airport extreme is flashing amber it says i need a ip address .... it was working just fine yesterday until i had to reboot cable modem how do i get my extreme to work again so i can have wireless..... please help!!!

    Hi again Jen,
    Most internet providers utilize "dhcp" -- you might want to check to see if your extreme is set to that function.
    If you want to try, you need to go into airport utility and select MANUAL setup/ then click NETWORK button on top of the window. /select TCP/IP -- make sure that you see "Using DHCP" not MANUAL in the configuration window.  If you do see using  dhcp, click the renew dhcp lease button.  Then you'd have to do the power down/up cycle again.  If all this doesn't work, you can do a hard reset on your Extreme, which will bring it back to the way it came out of the box, then go through the same proccess that was used to set it up originally.

  • Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Snow Lepard it work just perfectly... help please.

    Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Snow lepard it work just perfectly... help please.

    Reinstall MacFuse with the one from http://www.tuxera.com/mac/macfuse-core-10.5-2.1.9.dmg. If that doesn't work, you can use Paragon NTFS for Mac 9.0 which has been designed to work with Lion.

  • Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Lion it work just perfectly... help please.

    Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Lion it work just perfectly... help please.

    Sorry in my MBP Snow lepard it work.. don't have Lion In MBP

  • I want to email a photo through iPhoto but it says I need a password... I entered my password but it says it doesn't match - what password do they want and how do I fix? (Facebook and other social media iPhoto posts work - just email asking for pass)

    I want to email a photo through iPhoto but it says I need a password... I entered my password but it says it doesn't match - what password do they want and how do I fix? (Facebook and other social media iPhoto posts work - just email asking for password)

    Your email password.
    iPhoto '11: Email your photos
    Open Mac Mail. From the Mac Mail menu bar click Mail > Preferences then select the General tab.
    Make a selection from the:  Default email reader   pop up menu.

  • Hello All. I am working on a form, but I need to format the leading in a multi-line text-field.

    Hello All. I am working on a form, but I need to format the leading in a multi-line text-field. The options for the text-field only show a font size option, but no other styling options. Is there a way to format the leading? Thanks!

    Not within ID, and I'm not sure it can be done in Acrobat afterward either.

  • How Do I view text logs online? I know I can't see content, just need logs...THANKS!!!!

    I just need to get text messaging logs, HELP!!! I forgot how and it's extremely important! Thanks!

    To view text logs for the current billing period:
    Log into your on-line MyVerizon account
    Click the blue View Usage on the left-hand side
    Under the red Messaging, click the blue View Messaging Details
    To view your text logs for previous billing periods:
    When logged into your on-line MyVerizon account, click View Bill.
    Use the drop-down to select the appropriate bill.
    Click the Calls, Messages, & Data tab.
    Click the blue Messaging.
    Use the drop-down to select the appropriate line.
    Text message details are only available for the past 90 days.

  • On both my desktop and notebook, sync just stops working and needs to be set up again! Although my account is still there ?

    On both my desktop and notebook, sync just stops working and needs to be set up again! Although my account is still there ?
    I have windows 7 on both computers and I use the paid version of Roboform (which does not encounter any problems!) So, I really need my sync to work and keep working. Please help......

    Do you mean that after closing the browser your Sync set up is gone and you need to Set it up again?
    This is, generally, because your privacy settings are too restrictive and you are deleting the password of your Sync account.
    You can modify this in the Privacy tab of your Preferences/Options window. Select Remember History or Use Custom Settings in the drop down to configure the level that you want.

Maybe you are looking for

  • How to make the common control button for all pages in TABCONTROL​?

    Dear all,            I'm using TABCONTROL for my application. I'm having STOP and SAVE control. I have to show this button to all pages  in TABCONTROL.. How do i make it? Kindly help me?.. Regards, Srinivasan.P Solved! Go to Solution.

  • Open Items

    Hii.. We are creating a bank report for which we need a data from FBL3N open items on previous dates for this we are using table BSIS up to this everything is fine but problem is in FBL3N suppose if we give open items for 31.12.2008 or any other prev

  • Regarding Equipment master

    Hi Experts! I am SAP MDM consultant and I am working on a rquirement to model the Equipment Master Data in my repository. SAP MDM only requires master data from Equipment master. Kindly give me list of master data in Equipment master and give links e

  • UNABLE TO OPEN PDF ON MY MAC!

    Can someone help me with this error message below?  It is preventing me from opening PDF files on my MAC but not on my PC.  Thank you! "Adobe Reader could not open 'AIS_Research_Compression.pdf' because it is either not a supported file type or becau

  • SSL certificate issue with WLS 10.3

    Hi All, I am facing this issue with my WLS cluster. <21-Apr-2010 10:42:00 o'clock BST> <Warning> <Security> <BEA-090482> <BAD_CERTIF ICATE alert was received from system.core.com - 10.15.135.30. Check the peer to determine why it rejected the certifi