Registration failed

I am creating a app that requires the user to sign up but I am having problems . I am not getting any errors therefore I don’t know if i’m doing something wrong on the front end or back end . I am running code that is suppose to show all errors on my PHP side but I have no errors . In my corona sdk log , I get no errors . But when I try to sign up I get this else statement 

local alert = native.showAlert( "Error Signing Up", "There was an error signing up.", { "Try again" } )

I don’t know what is wrong with it can someone please help . 

register.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 email local function emptyFields( event ) if ( username.text == "" or pw.text == "" or pw2.text == "" or email.text == "" ) then local alert = native.showAlert( "Error", "Fill in all fields .", { "Try again" } ) return true else return false end end local function urlencode(str) if (str) then str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^%w])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") end return str end local function passwordMatch( event ) if ( pw.text ~= pw2.text ) then local alert = native.showAlert( "Error", "Passwords do not match .", { "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 json = require("json") json.prettify( event ) local alert = native.showAlert( "Error Signing Up", "There was an error signing up.", { "Try again" } ) end end end local function userRegister( event ) if ( "ended" == event.phase ) then if emptyFields() == true then else if passwordMatch() == true then else local parameters = {} parameters.body = "Register=1&username=" .. username.text .. "&pw=" .. pw.text .. "&pw2=" .. pw2.text .. "&email=" .. urlencode( email.text ) local URL = "http://hash.net16.net/register.php" network.request(URL, "POST", networkListener, parameters) end end end end local function loginLink( event ) if ( "ended" == event.phase ) then composer.gotoScene("login") end end

register.php:

\<?php ini\_set('display\_errors', 1); ini\_set('display\_startup\_errors', 1); error\_reporting(E\_ALL); $servername = "localhost"; $username = "username"; $password = "pass"; $database = "db"; $con = new mysqli($servername, $username, $password, $database); // Check connection if ($con-\>connect\_error) { die("Connection failed: " . $con-\>connect\_error); } echo "Connected successfully"; if(isset($\_POST['Register'])) { if (empty($\_POST["username"])) { echo"fill in username to sign up"; } else { if (empty($\_POST["pw"])) { echo"fill in password to sign up"; } else { if (empty($\_POST["pw2"])) { echo"confirm password to sign up"; } else { if (empty($\_POST["email"])) { echo"fill in email to sign up"; } else { if ($\_POST['pw'] == $\_POST['pw2']) { $username = mysqli\_real\_escape\_string($con, $\_POST["username"]); $pw= mysqli\_real\_escape\_string($con, $\_POST["pw"]); $email = mysqli\_real\_escape\_string($con, $\_POST["email"]); $result = mysqli\_query($con ,"SELECT \* FROM users WHERE username='" . $username . "'"); if(mysqli\_num\_rows($result) \> 0) { echo "Username exists"; } else { $result2 = mysqli\_query($con ,"SELECT \* FROM users WHERE email='" . $email. "'"); if(mysqli\_num\_rows($result2) \> 0) { echo "email exist"; } else { $sql = "INSERT INTO users (username, pw, email) VALUES('" . $username . "', '" . $pw . "', '" . $email . "')"; if(mysqli\_query($con, $sql)){ // if insert checked as successful echo username and password saved successfully echo"success"; }else{ echo mysqli\_error($con); } } } } else{ echo "The passwords do not match."; // and send them back to registration page }}}}} } ?\>

Please only ask your question once. If you don’t have an answer within 24 hours, on your original question, you can reply to your own question which will bump it back into view. This is called bumping and you can do it once every 24 hours. 

I’m going to lock this thread. If any one wishes to help, please reply on the original post:

https://forums.coronalabs.com/topic/69026-registration-error/

Thanks

Rob

Please only ask your question once. If you don’t have an answer within 24 hours, on your original question, you can reply to your own question which will bump it back into view. This is called bumping and you can do it once every 24 hours. 

I’m going to lock this thread. If any one wishes to help, please reply on the original post:

https://forums.coronalabs.com/topic/69026-registration-error/

Thanks

Rob