Registration form

It the database have any data in it?

nothing went in 

I just tested and it said success!

A duplicate entry is a valid result if you use the same username/email.

The question is did anything get in to the database?

[quote name=“brandont264” post=“336860” timestamp=“1471991824”]nothing went in [/quote]https://media4.giphy.com/media/5xtDarIX9MTLD1pMoXC/200w.gif

I said nothing went in first . 

No nothing went in the database . When I click register I get the else statement on Lua

wait i think something did go in 

And I tried it after you said nothing when it, so my question should have been “do you see anything **now**”.

Rob

And if I run again with the same username/email I get a “user exist” message, so it appears to be working.

No nothing is in it . I think the problem is in the lua code 

Yes I see it now

I’m not using the Lua code. I’m using the URL in the browser. It has to work here before we spend time trying to troubleshoot the client side.

In software development, you don’t want to be fixing A when the problem is with B and you’re trying to use A to test B. “B” has to be tested independently then you can work on A, if that makes any sense.

Yeah I see it now

Here is the URL I’m using:

http://hash.comxa.com/register.php?Register=1&username=testuserra&password=testpassword&password2=testpassword&email=testra%40email.com

It’s got to be finding testusera and testra@email.com in the database since I’m not getting a “user exists” message and earlier I got a “success” message. Let me change my values to something unique and double check.

You should be seeing a testusera and a testuserb in the database. What admin tool are you using to look at the database? PHPMyAdmin?

Yeah I see that in my database 

Now we can go to work on the Corona code. Can you post your latest code where you call network.request() and it’s listener function?

local function userRegister( event ) if ( "began" == event.phase ) then local URL = "http://hash.comxa.com/register.php?username=" .. ( username.text ) .. "&pw=" .. (pw.text) .. "&email=" .. ( email.text ) network.request(URL, "GET", networkListener) else print( "Something went wrong. Try again.") end end local function networkListener( event ) if ( event.isError ) then print( "Network error. ") else end end

Replace pw with password and add password2

But in my database it’s pw

Okay the first problem I see is a scope issue.  This function:

local function networkListener( event ) if ( event.isError ) then print( "Network error. ") else end end

has to be written in the code above:

local function userRegister( event ) if ( "began" == event.phase ) then local URL = "http://hash.comxa.com/register.php?username=" .. ( username.text ) .. "&pw=" .. (pw.text) .. "&email=" .. ( email.text ) network.request(URL, "GET", networkListener) else print( "Something went wrong. Try again.") end end

You are going to need a URL encoding function. I provided one way back at the beginning of the thread so I’ll repeat it here:

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

Place that above your networkListener function so it comes first of these three.

Now in your userRegister function change:

local URL = "http://hash.comxa.com/register.php?username=" .. ( username.text ) .. "&pw=" .. (pw.text) .. "&email=" .. ( email.text )

to

local URL = "http://hash.comxa.com/register.php?Register=1&username=" .. username.text .. "&password=" .. password.text .. "&password2=" .. password2.text .. "&email=" .. url\_encode( email.text )

Now your URL will be properly formatted. Note that I added a key-value pair:  Register=1. Your PHP script checks for the presence of a key named Register. I added password2 since your script is expecting two passwords to be passed. Finally I URL encode the email address.

That will get you working except for one thing. You don’t do anything with the output from the script. I’ll talk about that in the next message.