开发者

Flex PHP Login System Not Working Correctly

I wrote a login system using flex and php, but for some odd reason the php echos back both "true" and "false". Any ideas why this is happening?

<?php
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
//include("connect.php");   // used for your connection to the database.

$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);

// Temp username and password until hooked up to a database.
$strDetails[0] = "dennis";
$strDetails[1] = "test";

/开发者_如何学C/ DATABASE WORK HERE (grab the user)
/*<!--
$query = "SELECT username,password from users where username='$username' AND password='$password'";

while ($row = mysql_fetch_array($query)) {  // have not tested yet.
    if ($row['username'] == $username && $row['password'] == md5($password))    // If you don't want encryption take off md5
        echo "<login>true</login>";
    else
        echo "<login>false</login>";
}-->
*/

// Temp until hooked up to a database.
if ($username == $strDetails[0] && $password == $strDetails[1])
    echo "<login>true</login>";
else
    echo "<login>false</login>";

?>


I had a similar problem several months ago. For some reason one of my loops wasn't parsing correctly.

Can you try changing the Temp login validation to:

// Temp until hooked up to a database.
if (($username == $strDetails[0]) && ($password == $strDetails[1])) {
    echo "<login>true</login>";
} else {
    echo "<login>false</login>";
}

Let me know how you get on, if that doesn't fix it I'll dig up the old troublesome script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜