A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Flash/PHP/MySQL login

  1. #1
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323

    Flash/PHP/MySQL login

    I made two fields, user and pass. when you click login it sends these two fields to a php file.

    here is the php file contents:
    PHP Code:
    <?php
    $username 
    $_POST[user];
    $password $_POST[pass];
    $con mysql_connect("SERVER_GOES_HERE",$username,$password);
    if (!
    $con)
      {
      print 
    "&reply=didn't connect"
      
    }
    if(
    $con)
     {
    print 
    "&reply=win"
    }
    mysql_close($con)
    ?>

    As you can see i've replaced the server with SERVER_GOES_HERE.

    anyway every time i try it fails straight away saying that the php file didn't respond. what?

    Flash actionscript:

    Code:
    sender = new LoadVars();
    sender.user = user;
    sender.pass = pass;
    sender.sendAndLoad("login/login.php",sender,"POST");
    sender.onLoad = function(epicwin){
    if(epicwin){
    if(sender.reply=="win"){
    _root.login.gotoAndStop("account");
    }else{
    error = sender.reply;
    gotoAndStop("fail");
    }
    }else{
    error = "There was no response from the server!";
    gotoAndStop("fail");
    }
    }
    }
    Somebody help!

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Ouch, why are you posting the username and password for the database? That's horribly insecure. Seriously, don't ever do that. Your entire database can easily be compromised.

  3. #3
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    then how can i make a secure login for my site?
    please tell me!
    I had somebody hack into my site, i guess my password was easy but who cares I want a secure login that will be real hard to hack!

  4. #4
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Usernames and passwords are stored in a table in the database. And you'll authenticate against a row in the table.

    That way you can have multiple usernames and passwords too.

  5. #5
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    Ok cool thanks but this is an admin feature, I only want about 2 accounts. I suppose i will need to make the account manually then just access them in flash?

  6. #6
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    It doesn't matter. You need to create a "users" table. And inside that table keep track of the usernames and passwords.

    Seriously, if you picked up that book I pointed you towards, you'd understand all this stuff in no time.

  7. #7
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    what book?

  8. #8

  9. #9
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    I have some things to oppose that idea

    1) I can learn alot from the internet. i know its limited and stuff but I am learning!

    2) How do you buy it when you don't have a credit card

  10. #10
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    1) Yeah, we have the internet, but having a book reference comes in handy. And you tend to find a lot more information in a book, believe it or not. I live on the internet, but if I'm determined to learn a new subject, I always crack open a new book to take it in first. At least to build the foundation. It's also nice to have a book on your desk that you can take notes in, book mark, scribble, whatever in.

    2) I'm not sure. When I was your age, I asked my parents. My mom was a teacher and fully supported learning, so if I wanted a book, they just got it for me. Ask. Most parents are very supportive if you want to learn something.

  11. #11
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    1) yes i right ideas down

    2) okay!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center