简体   繁体   中英

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";

// 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM