Hello (excuse my english),
When a button is clicked I would like to write a simple data on my server.
For example when a guy clicks on a button of the game it buys an armor and this sends a data on the server in an array or file.
What is the simplest method with construct 2 tools ?
No idea ?
Develop games in your browser. Powerful, performant & highly capable.
You are looking for the AJAX object. It allows GET and POST requests:
In my experience, there are 2 gotchas:
1. Remember to properly escape any quotes "".
2. The format for sending POST data is the same as for GET. In the C2 manual it says:
[quote:2grndpef]Post to URL
Send a request with data to a URL and retrieve the response. A tag is provided to match it up with the On completed, On progress and On error triggers. Construct 2 does not automatically URL encode the post data - use the URLEncode system expression to ensure the data is in the correct format for posting. Note post data is in the same format as a query string, e.g. "foo=1&bar=2". The method can also be specified: by default it is POST, but for some APIs you may need to change this to PUT, DELETE or another HTTP method.
Thank you cjbruce for your answer.
Think otherwise that it is possible to write in a database given mysql ?
Yes, use AJAX to send data to a PHP script on your server. The PHP script can read from and write to a mysql database.
There are tutorials to help you get started.
You might find this plugin helpful:
I find this :
https://www.scirra.com/tutorials/525/si ... l-database
Yea, like that post (and others have said), you have to use some messaging protocol (HTTP AJAX, WebSockets, etc.) to pass information back to a server program which writes it to a database. PHP is the easiest server-side language to learn.
other good example for ajax beginner :