When I enter the username and password and click login I don’t go to the next screen if the login is successful . I entered the correct info but it’s not transitioning to the restricted screen .
login.lua
local composer = require( "composer" ) local scene = composer.newScene() local widget = require("widget") -- forward declare the text fields local json = require("json") local username local password 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 end end local function userLogin( event ) if ( "ended" == event.phase ) then if emptyFields() == true then else local URL = "http://hash.comxa.com/login.php?Login=1&username=" .. username.text .. "&pw=" .. pw.text network.request(URL, "GET", networkListener) end end end function scene:create(event) local screenGroup = self.view display.setDefault("background", 0, 3, 5) local icon = display.newImage("hash\_opt.png", 160, 70) screenGroup:insert(icon) local myText = display.newText( "#Hash", 160, 160, native.systemFontBold, 32 ) myText:setFillColor( 1, 2, 4.5 ) username = native.newTextField( 160, 200, 180, 30 ) -- take the local off since it's forward declared username.placeholder = "Username" screenGroup:insert(username) pw = native.newTextField( 160, 270,180, 30 ) -- take the local off since it's forward declared pw.isSecure = true pw.placeholder = "Password" screenGroup:insert(pw) local Button3 = widget.newButton( { shape = "roundedRect", left = 70, top = 350, id = "Login", label = "Login", onEvent = userLogin } ) screenGroup:insert(Button3) end function scene:show(event) composer.removeScene( "register" ) end function scene:hide(event) end function scene:destroy(event) end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) scene:addEventListener("destroy", scene) return scene
login.php
if(isset($\_GET['Login'])) { $username = mysqli\_real\_escape\_string($con, $\_GET["username"]); $pw= mysqli\_real\_escape\_string($con, $\_GET["pw"]); $result = "SELECT \* FROM users WHERE username='$username'"; $response = mysqli\_query($result); $row = mysqli\_fetch\_array($response); if($row['pw'] == $pw) { $\_SESSION['user'] = $row['username']; echo"logged in"; } else{ echo("Wrong Credentials"); } }