Results 1 to 9 of 9

Thread: submit password

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default submit password

    I want to create a text field, where the user has a password, upon verefication it proceeds to either go to a url or play a swf(I know how to do that part.)

    I just need a simple explanation or a tutorial that talks about verifying user input such as id and pasword.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I can do this simply with javascript or PHP, just not flash. I can(as that I mean try) to make it with PHP, a password(ecrypted) that will use ajax to send the data and if the data is correct then display the flash file, if it's not then go to the URL.
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by evan View Post
    I want to create a text field, where the user has a password, upon verefication it proceeds to either go to a url or play a swf(I know how to do that part.)

    I just need a simple explanation or a tutorial that talks about verifying user input such as id and pasword.
    What level of user authentication are you wanting to do here? Is this linked to a user database (e.g. mySQL)?

    If so, you're going to have to use a combination of PHP and AS for it to work. Flash can't directly connect to MySQL, but it can communicate with PHP. So, the workflow here would be to send whatever is entered through the input field to a PHP script that would authenticate the user and then reply back to Flash with some sort of signal (probably through a variable).

    If it's just a matter of a few usernames that you want to hard code, then we're just talking some basic conditionals:

    AS3:
    Code:
    submit.addEventListener(MouseEvent.CLICK, authenticate);
    function authenticate(e:MouseEvent):void {
       if(username.text == "John") {
          if(password.text == "Doe") }
             gotoAndPlay("successful_login");
          }
          else {
             status.text = "Incorrect Password";
          }
       }
       else {
          status.text = "Incorrect Username";
       }
    }
    AS2:
    Code:
    submit.onRelease = function() {
       if(username.text == "John") {
          if(password.text == "Doe") }
             gotoAndPlay("successful_login");
          }
          else {
             status.text = "Incorrect Password";
          }
       }
       else {
          status.text = "Incorrect Username";
       }
    }
    username and password are instance names for input fields. status would be another dyanamic text field that could display errors. Of course, if you're going to hard code more, you'll probably want to loop through an array or use switch/case syntax instead of repeating code blocks.


    Let me know if there is server-side scripting involved. I'll post an small example of how that's done if you need.

  4. The Following User Says Thank You to Medyman For This Useful Post:

    evan (06-30-2008)

  5. #4
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default It has errors

    1083: Syntax error: rightbrace is unexpected.

    then it tells me the else is unexpected
    bummer.

  6. #5
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by evan View Post
    1083: Syntax error: rightbrace is unexpected.

    then it tells me the else is unexpected
    bummer.

    That's what I get for typing directly into the forum. You might have figured it out as it's only a simple typo, but this is the correct way of writing that code:

    Code:
    submit.addEventListener(MouseEvent.CLICK, authenticate);
    function authenticate(e:MouseEvent):void {
       if(username.text == "John") {
          if(password.text == "Doe") {
             gotoAndPlay("successful_login");
          }
          else {
             status.text = "Incorrect Password";
          }
       }
       else {
          status.text = "Incorrect Username";
       }
    }
    I accidentally typed a right brace (}) instead of a left brace ({).
    Last edited by Medyman; 06-30-2008 at 08:01 PM.

  7. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Other way(another type):
    Quote Originally Posted by Medyman View Post
    I used a right brace ({) instead of a left brace (}).
    Just a tip: Don't tell people when there password is wrong, say username or password is wrong.
    Jeremy | jfein.net

  8. The Following User Says Thank You to Nile For This Useful Post:

    evan (06-30-2008)

  9. #7
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Nile View Post
    Other way(another type):

    Just a tip: Don't tell people when there password is wrong, say username or password is wrong.
    Man, i'm really out of it today. Thanks Nile. Fixed it in the orig. post.

    As for your suggestion -- I agree. I just added that so that it would be obvious what was happening there without using comments

  10. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Teheheehe, I didn't see the mix up between the names of the braces, but you said you accidently used a { instead of a }, but you really used a } instead of a {.
    Jeremy | jfein.net

  11. #9
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    While I was messing around I came up with:

    stop();
    var confirmPtI:Number=10;
    var confirmPtII:Number=10;
    submit.addEventListener(MouseEvent.CLICK, authenticate);
    function authenticate(e:MouseEvent):void {
    if(username.text == "Muppet")

    {confirmPtI=20;}
    if(password.text == "Chef")
    {confirmPtII=20;}
    if ( confirmPtI<15 && confirmPtII<15){gotoAndPlay("no");}else {gotoAndPlay("start");}
    }
    I can set it up to make a distinction between user or pwd incorrect. I know using variable looks silly but I hate getting caught up with {} mistakes -I do it too much to even realize whether I did that or made a more important coding error.

    Now, can anyone give me a rundown on getting this to work with SQL, as in doing something more advanced?

    Such as:

    User creates account:
    User logs in -->validate
    User logs incorrectly three times -selects one of two choices: create an account, OR forgot user name and pwd.

    I any good reading material on the subject also?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •