-
Login - Mysql - Flash - HELPPP!!!!!
Hello guys I have two problems (Hope someone can help me) AS2 please!:
1) I need to take my movie flash to another frame after login
2) I need to authenticate frame by frame the login (user)
Here is my Flash Login Button Code:
on (release) {
if (username != "" && pass != "") {
loadVariablesNum("login.php", 0, "POST");
_root.words = "Begin login process";
} else {
_root.words = "Please enter a username and password";
}
}
and my PHP Code:
<?php
mysql_connect("localhost","xxxxxxx","xxxxxxx") or die();
mysql_select_db("sincrom1_test") or die();
$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die();
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
print "words=User doesn't exist.&checklog=3";
die();
}
while($info = mysql_fetch_array( $check ))
{
if ($_POST['pass'] != $info['password']) {
print "words=Incorrect Password.&checklog=4";
die();
}else
{
print "words= $fullname You are logged in.&checklog=5";
die();
}
}
?>
What I'm doing wrong??
Help!
-
.
Hi,
Firstly you were not sending any vars to the php form, nor retrieving any, so you wold not have gotten any response.
So with a bit of alteration, as you did not attach your fla.
instead of placing the code on the button, put the code on the timeline where you can access it easier.
Also I suggest not using vars but use the textfield name instead.
Fla:
PHP Code:
var phpPath:String = "login.php"; var varsToSend:LoadVars; var varsToFetch:LoadVars;
passText.password = true;
logButton.onRelease = function() { if (userText.text != "" && passText.text != "") { varsToSend = new LoadVars(); varsToSend.username = userText.text; varsToSend.passname = passText.text; varsToFetch = new LoadVars(); varsToSend.sendAndLoad(phpPath,varsToFetch,"POST"); varsToFetch.onLoad = dataReturned; trace(varsToSend); } else { trace("Please fill in both username and password"); replyText.text = "Username and password required"; } };
function dataReturned(passed:Boolean) { if (passed) { replyText.text = this.words; } else { replyText.text = "Error connecting to server."; } }
this one does both username and password together, it would take a few more lines of code and my time to make it log in in stages.
This is not encrypted so anybody can view the password across the net, you might want to look into using sha1 or md5 or any form of encryption for future use.
php:
PHP Code:
<?php
error_reporting(E_ALL ^ E_DEPRECATED); $connect = mysql_connect("localhost","dataBaseOwner***","ownerPass***", "dataBaseName"); $dbase = mysql_select_db("dataBaseName", $connect);
$username = mysql_real_escape_string($_POST['username'],$connect); $password = mysql_real_escape_string($_POST['passname'],$connect);
$check = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $result = mysql_query($check) or die();
if (mysql_num_rows($result)) { while ($data = mysql_fetch_array($result)) { echo "words=This username and password are recognised, you are logged in."; } } else { echo "words=This username and password is not recognised."; mysql_close($connect); }
?>
I dont know what phph version you use at home but after 5.5 you will start to need to use mysqli
so this is added error_reporting(E_ALL ^ E_DEPRECATED);
http://stackoverflow.com/questions/2...-mysql-connect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|