Database and request http

I would like to create an application with a group chat over the Internet. I have already created such a thing in a website and I was wondering if it was possible to create such a thing using the database provided by corona SDK. In a nutshell, the database application is the same for everyone? In the sense that if I enter the information into the database via an http request to another user with the same application can see it?

Thanks in advance for clarification.

If you’ve got php on your server, you can probably setup a page your app can talk to( to login, lookup groups, join groups, read and post messages, etc).

The app would talk to your server via network.request() call to your php page, passing in parameters for what the user wanted to do.

All users would point to the same php page, which would ostensibly use the same database. You might even be able to use the same db your web app uses.

Well, thank you. I decided to make a request to my PHP page, but this shows the html tags (obviously). How can I put in the app what I receive the request?

local function networkListener( event )         if ( event.isError ) then                 print( "Network error!")         else                 print ( "RESPONSE: " .. event.response )         end     end network.request( "http://edonetwork.altervista.org/log.php", "GET", networkListener )

I don’t really understand your question. If you are receiving a response, then that’s great.

Many developers reply from the php with a json filled with data the app can easily process / use. Also, the requests I’ve seen have a little more parameters usually, such as:

[lua]

network.request( “http://edonetwork.altervista.org/log.php?action=1&name=fred&pass=987654321”, “GET”, networkListener )

[/lua]

The php code would branch on the particular action requested by the app. In the case of the login script, one action might to to login, and another to register a new user, for example (and the parameters passed might differ a bit too).

I get it. I return JSON from PHP page.
For a registration system, I can use the database of the app, right?

If so, how?

I don’t think you can use the apps sql support to manage the remote database. (You’d want the registration db on the server, so the user can login from different devices for example, or you could ban users, etc)

The way I’ve seen it done is that you would use a database on the server. People commonly use mySQL (you might be now), so using your server database, you’d make calls from your app to php, passing in parameters. The php would then add/remove/update the mySQL database, and reply with any message/data the app requested (all in a json passed back to the app).

If you’ve got php on your server, you can probably setup a page your app can talk to( to login, lookup groups, join groups, read and post messages, etc).

The app would talk to your server via network.request() call to your php page, passing in parameters for what the user wanted to do.

All users would point to the same php page, which would ostensibly use the same database. You might even be able to use the same db your web app uses.

Well, thank you. I decided to make a request to my PHP page, but this shows the html tags (obviously). How can I put in the app what I receive the request?

local function networkListener( event )         if ( event.isError ) then                 print( "Network error!")         else                 print ( "RESPONSE: " .. event.response )         end     end network.request( "http://edonetwork.altervista.org/log.php", "GET", networkListener )

I don’t really understand your question. If you are receiving a response, then that’s great.

Many developers reply from the php with a json filled with data the app can easily process / use. Also, the requests I’ve seen have a little more parameters usually, such as:

[lua]

network.request( “http://edonetwork.altervista.org/log.php?action=1&name=fred&pass=987654321”, “GET”, networkListener )

[/lua]

The php code would branch on the particular action requested by the app. In the case of the login script, one action might to to login, and another to register a new user, for example (and the parameters passed might differ a bit too).

I get it. I return JSON from PHP page.
For a registration system, I can use the database of the app, right?

If so, how?

I don’t think you can use the apps sql support to manage the remote database. (You’d want the registration db on the server, so the user can login from different devices for example, or you could ban users, etc)

The way I’ve seen it done is that you would use a database on the server. People commonly use mySQL (you might be now), so using your server database, you’d make calls from your app to php, passing in parameters. The php would then add/remove/update the mySQL database, and reply with any message/data the app requested (all in a json passed back to the app).