PHP Lua система входа

Я пытаюсь создать систему входа в систему для своего приложения, но когда я ввожу правильные данные пользователя, я получаю инструкцию Lua else. Я пытался решить это с помощью и самостоятельно, но никто не имеет ответа на проблему. Кто-нибудь может мне помочь? Даже если это просто решение части проблемы. Спасибо

login.php:

             // Check connection
             if ($con->connect_error) {
             die("Check connection.");
                }

                 $username = ($_POST["username"]);
                 $pw = ($_POST["pw"]);

                 if(isset($_POST['Login'])) {

                    $username = mysqli_real_escape_string($con, $_POST["username"]);
                    $pw = mysqli_real_escape_string($con, $_POST["pw"]);

                    $result = mysqli_query($con ,"SELECT * FROM users WHERE username = '" . $username . "' AND pw = '" . $pw . "' ");

                if($result == 1){

                $_SESSION['logged in'] = true;
                echo"success";
                }
                else
                {
                echo"username or password is incorrect.";
                }
 }

login.lua:

local username
local pw

local function emptyFields( event )
if ( username.text == "" or pw.text == "" ) then

      local alert = native.showAlert( "Empty fields", "Fill in all fields .", { "Try again" }  )

    return true 

    else
    return false

  end
end

local function networkListener( event )

if ( event.isError ) then
    print( "Network error.")
else
    if event.response == "success" then
        -- put the code here to go to where the user needs to be
        -- after a successful registration
        composer.gotoScene("userarea")

    else
        -- put code here to notify the user of the problem, perhaps
        -- a native.alert() dialog that shows them the value of    event.response
        -- and take them back to the registration screen to let them try again

      local alert = native.showAlert( "Error Logging In", "There was an error logging in.", { "Try again" }  )

end

конец конец

local function userLogin( event )
if ( "ended" == event.phase ) then
 if emptyFields() == true then  

    else

    local parameters = {}
    parameters.body = "Login=1&username=" .. username.text .. "&pw=" .. pw.text

    local URL = "http://hash.comxa.com/login.php"
    network.request(URL, "POST", networkListener, parameters)

    local headers = {} 

    headers["Content-Type"] = "application/x-www-form-urlencoded" 
    headers["Accept-Language"] = "en-US"

    parameters.headers = headers

end
end
end

Это еще одно утверждение, которое я получаю:

      local alert = native.showAlert( "Error Logging In", "There was an error logging in.", { "Try again" }  )

0 ответов

Другие вопросы по тегам