http post

having a little bit of trouble with updating database via php http post.

local http = require(“socket.http”)

local query = “score=”…score

http.request( “http://127.0.0.1/score.php”, query )

doesnt seem to be hitting the post parameter ‘score’

what am i doing wrong??

I’m assuming you’re trying to send some data to an external service that’ll then place it in a db… as a GET:

network = require “network”

local headers = {}

headers[“Content-Type”] = “application/x-www-form-urlencoded”

headers[“Accept-Language”] = “en-US”

local parameters = {}

parameters.headers = headers

local body = “?score=” …score

myURL = “http://127.0.0.1/score.php” … body

network.request( myURL, “GET”, myListener, parameters )

Your PHP/.NET/RoR would pick this up as a form submission, which you can clean out the data from and put it in the web service database. Don’t forget to add the myListener function to wait for a thumbs up/down returned from your web service.

More here: http://docs.coronalabs.com/daily/api/library/network/request.html

yep thanks ill give this a go

what about the post method with coronasdk for when you are catching the variable in .php via $_POST

?

Take a look at the example “HTTP POST with Custom Headers” at the documentation page: http://docs.coronalabs.com/daily/api/library/network/request.html

That’s the best example on using network.request for POST requests to a website.

Hope that helps.

I’m assuming you’re trying to send some data to an external service that’ll then place it in a db… as a GET:

network = require “network”

local headers = {}

headers[“Content-Type”] = “application/x-www-form-urlencoded”

headers[“Accept-Language”] = “en-US”

local parameters = {}

parameters.headers = headers

local body = “?score=” …score

myURL = “http://127.0.0.1/score.php” … body

network.request( myURL, “GET”, myListener, parameters )

Your PHP/.NET/RoR would pick this up as a form submission, which you can clean out the data from and put it in the web service database. Don’t forget to add the myListener function to wait for a thumbs up/down returned from your web service.

More here: http://docs.coronalabs.com/daily/api/library/network/request.html

yep thanks ill give this a go

what about the post method with coronasdk for when you are catching the variable in .php via $_POST

?

Take a look at the example “HTTP POST with Custom Headers” at the documentation page: http://docs.coronalabs.com/daily/api/library/network/request.html

That’s the best example on using network.request for POST requests to a website.

Hope that helps.