Login error

I am trying to create code to let my users login . I tried fixing both sides (PHP and Lua) but I’m not getting anywhere . This is the same code I’m using in my website code so I don’t see why it’s not working . 

loging.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 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 local alert = native.showAlert( "Error Logging In", "Check your internet connection .", { "Try again" } ) 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 json = require("json") print( json.prettify( event ) ) 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 parameters = {} parameters.body = "Login=1&username=" .. username.text .. "&pw=" .. pw.text local URL = "http://site.net16.net/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 function registerLink( event ) if ( "ended" == event.phase ) then composer.gotoScene("register") end end function scene:create(event) local screenGroup = self.view local background = display.newImageRect("bg4.jpg",display.contentWidth,display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY screenGroup:insert(background) myImage = display.newImage( "hash.png" ) -- position the image myImage:translate( 160, 70 ) myText = display.newText( "#Hash", 160, 140, native.systemFontBold, 40 ) myText:setFillColor( 1, 1, .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 = 320, id = "Login", label = "Login", onEvent = userLogin, fillColor = { default={ 0, 1, 4, 0.7 }, over={ 1, 0.5, 0.8, 4 } }, labelColor = { default={ 2, 4, 1.5 }, over={ 2, 5, 1.5, 2.2 } } } ) screenGroup:insert(Button3) local Button4 = widget.newButton( { shape = "roundedRect", left = 70, top = 410, id = "register", label = "Register Here", onEvent = registerLink, fillColor = { default={ 2, 4, 0, 0.7 }, over={ 1, 3, 8, 4 } }, labelColor = { default={ 2, 4, 1.5 }, over={ 2, 5, 1.5, 2.2 } } } ) screenGroup:insert(Button4) end function scene:show(event) composer.removeScene( "register" ) end function scene:hide(event) myText:removeSelf() username:removeSelf() pw:removeSelf() myImage:removeSelf() 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:

\<?php error\_reporting(E\_ALL); ini\_set('display\_errors', 1); include("connect.php"); $\_SESSION['username'] = $\_POST['username']; //check if form is submitted if ( $\_SERVER['REQUEST\_METHOD'] != 'POST' || ! isset($\_POST['signin'])) { // looks like a hack, send to index.php header('Location: index.php'); die(); } if (empty($\_POST["username"])) { echo 'fill in username to sign in. \<a href= index.php\>Try again\</a\>\<br /\>'; die(); } if (empty($\_POST["pw"])) { echo 'fill in password to sign in. \<a href= index.php\>Try again\</a\>\<br /\>'; die(); } $sql = "SELECT pw FROM users WHERE username = ?"; $stmt = mysqli\_prepare($conn, $sql); if ( !$stmt ) { echo mysqli\_error($conn); die(); } $stmt-\>bind\_param('s', $\_POST['username']); if ( !$stmt-\>execute() ) { echo mysqli\_error($conn); die(); } // we found a row with that username, // now we need to check the password is correct // get the password from the row $stmt-\>bind\_result($hashed\_pwd); $stmt-\>fetch(); if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; header('Location: profile.php'); } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; } ?\>

For the hundredth time, what isn’t working? What errors do you get? What behaviour do you expect to see and what do you actually see? People really haven’t got time to spend half an hour going through your code to figure out how it should work and where it breaks down, especially when they can’t run it themselves.

And based on your other posts you’re struggling with simple concepts like composer event phases, I’d probably try and get that nailed down before going near network traffic and PHP!  :blink:

I totally agree with @nick you can’t just dump a lot of code and say “fix it” as we have better things to do!

But to give you a head start…  You are checking for “success” but where is that ever returned from your script?

I have this code running to show my response :

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

When I look in the console.log I get this part from the ‘Response’ :

"\<!doctype html\>\n\<html\>\n\<head\>\n \<meta charset=utf-8\>\n \<meta content=\"width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no\" name=viewport\>\n \<meta name=\"HandheldFriendly\" content=\"True\"\>\n \<title\>Error 404 (Not Found) | 000webhost\</title\>\n \<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"https://cdn.rawgit.com/000webhost/logo/master/favicon.ico\"\>\n \<style\>html, body {\n font-family: sans-serif;\n -ms-text-size-adjust: 100%;\n -webkit-text-size-adjust: 100%;\n background-color: #F7F8FB;\n height: 100%;\n -webkit-font-smoothing: antialiased;\n }\n\n body {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n }\n\n .message {\n text-align: center;\n align-self: center;\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 0px 20px;\n max-width: 450px;\n }\n\n .message\_\_title {\n font-size: 22px;\n font-weight: 100;\n margin-top: 15px;\n color: #47494E;\n margin-bottom: 8px;\n }\n\n p {\n -webkit-margin-after: 0px;\n -webkit-margin-before: 0px;\n font-size: 15px;\n color: #7F828B;\n line-height: 21px;\n margin-bottom: 4px;\n }\n\n .btn {\n text-decoration: none;\n padding: 8px 15px;\n border-radius: 4px;\n margin-top: 10px;\n font-size: 14px;\n color: #7F828B;\n border: 1px solid #7F828B;\n }\n\n .hk-logo, .app-icon {\n fill: #DBE1EC;\n }\n\n .info {\n fill: #9FABBC;\n }\n\n body.friendly {\n background: -webkit-linear-gradient(-45deg, #b80303 0%, #000 100%);\n background: linear-gradient(135deg, #b80303 0%, #000 100%);\n }\n\n body.friendly .message\_\_title {\n color: #fff;\n }\n\n body.friendly p {\n color: rgba(255, 255, 255, 0.6);\n }\n\n body.friendly .hk-logo, body.friendly .app-icon {\n fill: rgba(255, 255, 255, 0.9);\n }\n\n body.friendly .info {\n fill: rgba(255, 255, 255, 0.9);\n }\n\n body.friendly .btn {\n color: #fff;\n border: 1px solid rgba(255, 255, 255, 0.9);\n }\n\n .info\_area {\n position: fixed;\n right: 12px;\n bottom: 12px;\n }\n\n .logo {\n position: fixed;\n left: 12px;\n bottom: 12px;\n }\n #footer {\n display: none;\n }\n \</style\>\n\</head\>\n\<body\>\n \<div class=spacer\>\</div\>\n \<div class=message\>\n \<div class=message\_\_title\>404. That’s an error.\</div\>\n \<p\>The requested URL was not found on this server.\</p\>\n \</div\>\n \<div class=logo\>\n \<img src=\"https://raw.githubusercontent.com/000webhost/logo/d1cf5cdf/000webhost-logo-forum-33x33.png\" alt=\"000webhost\"\>\n \</div\>\n \<div class=info\_area\>\<a href=\"https://www.000webhost.com/website-faq?utm\_source=000&utm\_medium=40x&utm\_campaign=pages\" target=\_blank\>\n \<svg width=24 height=24 xmlns=\"http://www.w3.org/2000/svg\"\>\<path d=\"M12 24c6.6274 0 12-5.3726 12-12S18.6274 0 12 0 0 5.3726 0 12s5.3726 12 12 12zm0-1.25c5.937 0 10.75-4.813 10.75-10.75S17.937 1.25 12 1.25 1.25 6.063 1.25 12 6.063 22.75 12 22.75zM12.9653 8C12.0593 8 11.5 7.25 11.5 6.519c0-.824.6805-1.519 1.587-1.519 1.0465 0 1.413.7506 1.413 1.3728C14.5005 7.396 13.7682 8 12.9653 8zM9.3 18.021c.3237-2.1306 1.5255-4.9562 1.772-6.6087l-1.2013-.043c0-.6092 0-1.1962.0155-1.7824C11.0566 9.3907 12.6125 9 12.89 9c.123 0 .585.565.724.8913-.277 1.8268-1.7406 6.174-1.864 6.979-.0156.087-.0156.1742.0467.1742.1534 0 .5543-.087.9856-.218.031.566.0772 1.1304.1076 1.6962-.6934.282-1.541.4773-2.8654.4773-.1235 0-.6165-.6094-.7246-.979z\" class=info fill-rule=evenodd /\>\</svg\>\n \</a\>\n \</div\>\n\n \<!-- google\_ad\_section\_start(weight=ignore) --\>\n \<div id=\"footer\"\>\n \<div\>\n \<div class=\"c0\"\>\n \<h4\>Upgrade To Pro\</h4\>\n \<a class=\"button-primary\" href=\"https://www.hostinger.com/special/000webhost?utm\_source=000&utm\_medium=erp&utm\_campaign=nla\"\>Go Premium\</a\>\n \<p class=\"hostinger\"\>\n \<a class=\"hostinger-logo\" href=\"https://www.hostinger.com/?utm\_source=000&utm\_medium=erp&utm\_campaign=nla&utm\_content=f1\"\>Hostinger\</a\>\<span\> Production\</span\>\n \</p\>\n \</div\>\n \<div class=\"c1\"\>\n \<h4\>Even more\</h4\>\n \<ul\>\n \<li\>\<a href=\"https://www.000webhost.com/features\" title=\"A sampling of the many features 000webhost.com offers\" \>Features\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/free-wordpress-hosting\" title=\"Free WordPress hosting to get started\" \>Free WordPress Hosting\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/free-joomla-hosting\" title=\"Free Joomla hosting to get started\" \>Free Joomla Hosting\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/templates\" title=\"000webhost Themes for websites at 000webhost.com\"\>Free Website Templates\</a\>\</li\>\n \</ul\>\n \</div\>\n \<div class=\"c2\"\>\n \<h4\>Community\</h4\>\n \<ul\>\n \<li\>\<a href=\"https://www.hostinger.com/?utm\_source=000&utm\_medium=erp&utm\_campaign=nla&utm\_content=f2\" title=\"We are here to help you\"\>Expert support\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/forum\" title=\"Communicate with your fellow 000webhost.com web developers\"\>Community support\</a\>\</li\>\n \</ul\>\n \</div\>\n \<div class=\"c3\"\>\n \<h4\>Company \<span style=\"display:none;\"\>\<a href=\"https://www.facebook.com/000webhost.Global/\"\>F\</a\> &#8226; \<a href=\"https://twitter.com/000webhost\_com\"\>T\</a\>\</span\>\</h4\>\n \<ul\>\n \<li\>\<a href=\"https://www.hostinger.com/web-hosting-companies?utm\_source=000&utm\_medium=erp&utm\_campaign=nla&utm\_content=f3\" title=\"A short introduction to your hosts\" \>Our story\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/privacy\" title=\"000webhost is completely not interested in your personal details\"\>Privacy Policy\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/terms-of-service\" title=\"Some legalese\"\>Terms of service\</a\>\</li\>\n \</ul\>\n \</div\>\n \</div\>\n \</div\>\n \<!-- google\_ad\_section\_end --\>\n\<div style='text-align: right;position: fixed;z-index:9999999;bottom: 0; width: 100%;cursor: pointer;line-height: 0;'\>\<a title=\"Hosted on free web hosting 000webhost.com. Host your own website for FREE.\" target=\"\_blank\" href=\"https://www.000webhost.com/?utm\_source=000webhostapp&utm\_campaign=000\_logo&utm\_medium=website\_btisson13&utm\_content=footer\_img\"\>\<img src=\"https://cloud.githubusercontent.com/assets/23024110/20663010/9968df22-b55e-11e6-941d-edbc894c2b78.png\" alt=\"www.000webhost.com\"\>\</a\>\</div\>\</body\>\n\</html\>",

I don’t know what’s wrong I’ve check 4 times and I don’t see any errors. I checked my code , changed it around and nothing worked . I have an example site so I used the exact same code because it works with my site but it’s not working here . I made sure everything matched the database and that the variables on both the PHP and Lua ends match but I don’t know . I have this code now

login.php :

\<?php $servername = "localhost"; $username = "id1662780\_hashh"; $password = "bigman23"; $database = "id1662780\_hash"; $con = new mysqli($servername, $username, $password, $database); if($con == true) { } // Check connection if ($con-\>connect\_error) { die("Connection failed: " . $con-\>connect\_error); } $\_SESSION['username'] = $\_POST['username']; if (empty($\_POST["username"])) { echo 'fill in username to sign in. \<a href= index.php\>Try again\</a\>\<br /\>'; die(); } if (empty($\_POST["pw"])) { echo 'fill in password to sign in. \<a href= index.php\>Try again\</a\>\<br /\>'; die(); } $sql = "SELECT pw FROM users WHERE username = ?"; $stmt = mysqli\_prepare($con, $sql); if ( !$stmt ) { echo mysqli\_error($con); die(); } $stmt-\>bind\_param('s', $\_POST['username']); if ( !$stmt-\>execute() ) { echo mysqli\_error($conn); die(); } // we found a row with that username, // now we need to check the password is correct // get the password from the row $stmt-\>bind\_result($hashed\_pwd); $stmt-\>fetch(); if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; } ?\>

The answer is so obvious… You don’t listen (nor act on advice) so I am not helping you anymore.

It’s a shame comeUp264, you have had advice and help from the developer of a hugely successful game that pushes Corona to its limits in Designer City, and Ed (roaminggamer) who is a superb Corona all-rounder who’s made every type of game you can think of. If only you would take notice of what they say!

I just changed my PHP code and this is what I got :

"response":"",

I got it now . I reread this answer and I had to change this :

if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; header('Location: profile.php'); } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; }

To this :

if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; echo"success"; } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; }

For the hundredth time, what isn’t working? What errors do you get? What behaviour do you expect to see and what do you actually see? People really haven’t got time to spend half an hour going through your code to figure out how it should work and where it breaks down, especially when they can’t run it themselves.

And based on your other posts you’re struggling with simple concepts like composer event phases, I’d probably try and get that nailed down before going near network traffic and PHP!  :blink:

I totally agree with @nick you can’t just dump a lot of code and say “fix it” as we have better things to do!

But to give you a head start…  You are checking for “success” but where is that ever returned from your script?

I have this code running to show my response :

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

When I look in the console.log I get this part from the ‘Response’ :

"\<!doctype html\>\n\<html\>\n\<head\>\n \<meta charset=utf-8\>\n \<meta content=\"width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no\" name=viewport\>\n \<meta name=\"HandheldFriendly\" content=\"True\"\>\n \<title\>Error 404 (Not Found) | 000webhost\</title\>\n \<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"https://cdn.rawgit.com/000webhost/logo/master/favicon.ico\"\>\n \<style\>html, body {\n font-family: sans-serif;\n -ms-text-size-adjust: 100%;\n -webkit-text-size-adjust: 100%;\n background-color: #F7F8FB;\n height: 100%;\n -webkit-font-smoothing: antialiased;\n }\n\n body {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n }\n\n .message {\n text-align: center;\n align-self: center;\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 0px 20px;\n max-width: 450px;\n }\n\n .message\_\_title {\n font-size: 22px;\n font-weight: 100;\n margin-top: 15px;\n color: #47494E;\n margin-bottom: 8px;\n }\n\n p {\n -webkit-margin-after: 0px;\n -webkit-margin-before: 0px;\n font-size: 15px;\n color: #7F828B;\n line-height: 21px;\n margin-bottom: 4px;\n }\n\n .btn {\n text-decoration: none;\n padding: 8px 15px;\n border-radius: 4px;\n margin-top: 10px;\n font-size: 14px;\n color: #7F828B;\n border: 1px solid #7F828B;\n }\n\n .hk-logo, .app-icon {\n fill: #DBE1EC;\n }\n\n .info {\n fill: #9FABBC;\n }\n\n body.friendly {\n background: -webkit-linear-gradient(-45deg, #b80303 0%, #000 100%);\n background: linear-gradient(135deg, #b80303 0%, #000 100%);\n }\n\n body.friendly .message\_\_title {\n color: #fff;\n }\n\n body.friendly p {\n color: rgba(255, 255, 255, 0.6);\n }\n\n body.friendly .hk-logo, body.friendly .app-icon {\n fill: rgba(255, 255, 255, 0.9);\n }\n\n body.friendly .info {\n fill: rgba(255, 255, 255, 0.9);\n }\n\n body.friendly .btn {\n color: #fff;\n border: 1px solid rgba(255, 255, 255, 0.9);\n }\n\n .info\_area {\n position: fixed;\n right: 12px;\n bottom: 12px;\n }\n\n .logo {\n position: fixed;\n left: 12px;\n bottom: 12px;\n }\n #footer {\n display: none;\n }\n \</style\>\n\</head\>\n\<body\>\n \<div class=spacer\>\</div\>\n \<div class=message\>\n \<div class=message\_\_title\>404. That’s an error.\</div\>\n \<p\>The requested URL was not found on this server.\</p\>\n \</div\>\n \<div class=logo\>\n \<img src=\"https://raw.githubusercontent.com/000webhost/logo/d1cf5cdf/000webhost-logo-forum-33x33.png\" alt=\"000webhost\"\>\n \</div\>\n \<div class=info\_area\>\<a href=\"https://www.000webhost.com/website-faq?utm\_source=000&utm\_medium=40x&utm\_campaign=pages\" target=\_blank\>\n \<svg width=24 height=24 xmlns=\"http://www.w3.org/2000/svg\"\>\<path d=\"M12 24c6.6274 0 12-5.3726 12-12S18.6274 0 12 0 0 5.3726 0 12s5.3726 12 12 12zm0-1.25c5.937 0 10.75-4.813 10.75-10.75S17.937 1.25 12 1.25 1.25 6.063 1.25 12 6.063 22.75 12 22.75zM12.9653 8C12.0593 8 11.5 7.25 11.5 6.519c0-.824.6805-1.519 1.587-1.519 1.0465 0 1.413.7506 1.413 1.3728C14.5005 7.396 13.7682 8 12.9653 8zM9.3 18.021c.3237-2.1306 1.5255-4.9562 1.772-6.6087l-1.2013-.043c0-.6092 0-1.1962.0155-1.7824C11.0566 9.3907 12.6125 9 12.89 9c.123 0 .585.565.724.8913-.277 1.8268-1.7406 6.174-1.864 6.979-.0156.087-.0156.1742.0467.1742.1534 0 .5543-.087.9856-.218.031.566.0772 1.1304.1076 1.6962-.6934.282-1.541.4773-2.8654.4773-.1235 0-.6165-.6094-.7246-.979z\" class=info fill-rule=evenodd /\>\</svg\>\n \</a\>\n \</div\>\n\n \<!-- google\_ad\_section\_start(weight=ignore) --\>\n \<div id=\"footer\"\>\n \<div\>\n \<div class=\"c0\"\>\n \<h4\>Upgrade To Pro\</h4\>\n \<a class=\"button-primary\" href=\"https://www.hostinger.com/special/000webhost?utm\_source=000&utm\_medium=erp&utm\_campaign=nla\"\>Go Premium\</a\>\n \<p class=\"hostinger\"\>\n \<a class=\"hostinger-logo\" href=\"https://www.hostinger.com/?utm\_source=000&utm\_medium=erp&utm\_campaign=nla&utm\_content=f1\"\>Hostinger\</a\>\<span\> Production\</span\>\n \</p\>\n \</div\>\n \<div class=\"c1\"\>\n \<h4\>Even more\</h4\>\n \<ul\>\n \<li\>\<a href=\"https://www.000webhost.com/features\" title=\"A sampling of the many features 000webhost.com offers\" \>Features\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/free-wordpress-hosting\" title=\"Free WordPress hosting to get started\" \>Free WordPress Hosting\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/free-joomla-hosting\" title=\"Free Joomla hosting to get started\" \>Free Joomla Hosting\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/templates\" title=\"000webhost Themes for websites at 000webhost.com\"\>Free Website Templates\</a\>\</li\>\n \</ul\>\n \</div\>\n \<div class=\"c2\"\>\n \<h4\>Community\</h4\>\n \<ul\>\n \<li\>\<a href=\"https://www.hostinger.com/?utm\_source=000&utm\_medium=erp&utm\_campaign=nla&utm\_content=f2\" title=\"We are here to help you\"\>Expert support\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/forum\" title=\"Communicate with your fellow 000webhost.com web developers\"\>Community support\</a\>\</li\>\n \</ul\>\n \</div\>\n \<div class=\"c3\"\>\n \<h4\>Company \<span style=\"display:none;\"\>\<a href=\"https://www.facebook.com/000webhost.Global/\"\>F\</a\> &#8226; \<a href=\"https://twitter.com/000webhost\_com\"\>T\</a\>\</span\>\</h4\>\n \<ul\>\n \<li\>\<a href=\"https://www.hostinger.com/web-hosting-companies?utm\_source=000&utm\_medium=erp&utm\_campaign=nla&utm\_content=f3\" title=\"A short introduction to your hosts\" \>Our story\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/privacy\" title=\"000webhost is completely not interested in your personal details\"\>Privacy Policy\</a\>\</li\>\n \<li\>\<a href=\"https://www.000webhost.com/terms-of-service\" title=\"Some legalese\"\>Terms of service\</a\>\</li\>\n \</ul\>\n \</div\>\n \</div\>\n \</div\>\n \<!-- google\_ad\_section\_end --\>\n\<div style='text-align: right;position: fixed;z-index:9999999;bottom: 0; width: 100%;cursor: pointer;line-height: 0;'\>\<a title=\"Hosted on free web hosting 000webhost.com. Host your own website for FREE.\" target=\"\_blank\" href=\"https://www.000webhost.com/?utm\_source=000webhostapp&utm\_campaign=000\_logo&utm\_medium=website\_btisson13&utm\_content=footer\_img\"\>\<img src=\"https://cloud.githubusercontent.com/assets/23024110/20663010/9968df22-b55e-11e6-941d-edbc894c2b78.png\" alt=\"www.000webhost.com\"\>\</a\>\</div\>\</body\>\n\</html\>",

I don’t know what’s wrong I’ve check 4 times and I don’t see any errors. I checked my code , changed it around and nothing worked . I have an example site so I used the exact same code because it works with my site but it’s not working here . I made sure everything matched the database and that the variables on both the PHP and Lua ends match but I don’t know . I have this code now

login.php :

\<?php $servername = "localhost"; $username = "id1662780\_hashh"; $password = "bigman23"; $database = "id1662780\_hash"; $con = new mysqli($servername, $username, $password, $database); if($con == true) { } // Check connection if ($con-\>connect\_error) { die("Connection failed: " . $con-\>connect\_error); } $\_SESSION['username'] = $\_POST['username']; if (empty($\_POST["username"])) { echo 'fill in username to sign in. \<a href= index.php\>Try again\</a\>\<br /\>'; die(); } if (empty($\_POST["pw"])) { echo 'fill in password to sign in. \<a href= index.php\>Try again\</a\>\<br /\>'; die(); } $sql = "SELECT pw FROM users WHERE username = ?"; $stmt = mysqli\_prepare($con, $sql); if ( !$stmt ) { echo mysqli\_error($con); die(); } $stmt-\>bind\_param('s', $\_POST['username']); if ( !$stmt-\>execute() ) { echo mysqli\_error($conn); die(); } // we found a row with that username, // now we need to check the password is correct // get the password from the row $stmt-\>bind\_result($hashed\_pwd); $stmt-\>fetch(); if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; } ?\>

The answer is so obvious… You don’t listen (nor act on advice) so I am not helping you anymore.

It’s a shame comeUp264, you have had advice and help from the developer of a hugely successful game that pushes Corona to its limits in Designer City, and Ed (roaminggamer) who is a superb Corona all-rounder who’s made every type of game you can think of. If only you would take notice of what they say!

I just changed my PHP code and this is what I got :

"response":"",

I got it now . I reread this answer and I had to change this :

if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; header('Location: profile.php'); } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; }

To this :

if ( password\_verify($\_POST['pw'], $hashed\_pwd) ) { // password verified $\_SESSION["username"] = $\_POST['username']; echo"success"; } else { echo 'Incorrect username or Password. \<a href= index.php\>Try again\</a\>\<br /\>'; }