I created php and as3 code for a website login interface. Here's the PHP code:
<?php
$con = mysql_connect("xxx", "xxx", "xxx");
mysql_query($con);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxx", $con) or die('no02');
$username = $_POST['username'];
$pass = md5($_POST['pass']);
if ($_POST['systemCall'] == "checkLogin") {
$select = "SELECT username FROM connexion WHERE username='$username' AND pass='$pass'";
$query = mysql_query($select);
$counter = 1;
while ($row = mysql_fetch_array($query)) {
$name = $row['username'];
if ($name == "joe") {
print "systemResult=joe";
}
$counter = $counter + 1;
}
}
mysql_close($con);
?>
Here's the AS3 code :
function dataOnLoad(e: Event) //after pressing submit button
{
status1.selectable = false;
status1.text = e.target.data.systemResult
status1.autoSize = TextFieldAutoSize.LEFT;
if (e.target.data.systemResult == "joe") {
MovieClip(root).gotoAndStop(3);
} else {
status2.text = "Doesn't work";
}
}
Now, every time I press the submit button with the right username and password, I get the right e.target.data.systemResult into status1.text, but I can't figure out why the if statement isn't recognizing the equality between e.target.data.systemResult and joe. It always writes "Doesn't work" into status2.text.
?>. You can remove?>, it is optional.