-
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!
-
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.
-
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!
-
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.
-
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?
-
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.
-
-
-
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
-
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.
-
1) yes i right ideas down
2) okay!