0

I am pretty new with this. I am trying to develop some android application in Qt/Qml to query and update data to a database.

The problem I'm trying to solve:

There is a server with a MySQL database. The android application request some data. I use a very very basic php file that query in the database, format an XML and show that file starting with a header('Content-type: text/xml'); sentence, then some echo "<...>" sentences. This php file receives parameters via $_GET array and performs the query.

This is a little archaic but works fine. My client application use Qt/QML for android. It uses XmlListModel to obtain the data from the server and show that data in a ListView.

So far so good, but here is my real problem:

The user of the android application can change some data, and the modified data must be sent back to the server, who performs an update in the database.

My first attempt was to create another php file and send the data in the URI, get it via $_GET and perform the update to the database. This works but there could be many variables and the URI will become very large. I think might be better to send an XML (or JSON) from the client to the server, and put in that file the data for the update.

So, this is the question: How can I send an XML file from Qt/QML to the server? How does the php file obtain that data? Or maybe there is another, better way for doing this.

Every example I find just shows the server-to-client part, or is written in Java, and I don't know java enough.

Additional notes:

  • After I can solve this I will fight with security: SSL, avoiding SQL injection or anything, but that will be in another question if necessary.
  • I didn't use SOAP or similar because the first ideas was simple. Also, I have never used SOAP before. If this is the right way, I would be very grateful if you show me how to use it from Qt/QML in android.
  • Of course, I can use C++ for the client application since it is using Qt.
  • I use Qt since I already know it and the app might be useful in desktop as well.

Sorry if I made any english mistake. Thank you in advance.

Daniel
  • 2,657
  • 1
  • 17
  • 22
  • You should split into two questions. First solve the server problem. PHP developers will help you. Later you can ask hot to submit a XML file to the server using _pattern X_ (the pattern that PHP developers will help you choose). – vinipsmaker Mar 13 '14 at 02:26
  • If you want to stay in PHP you could use $_POST request which you will need as soon as you send files back to the server. There is an small exaple at w3schools: http://www.w3schools.com/php/php_file_upload.asp As an alternative you could directly connect to the mysql Server and remove the whole php part. For sending files with Qt you will need to create a valid HTTP POST Request. There is already a similar topic for post JSON requests: http://stackoverflow.com/questions/12487620/correct-format-for-http-post-using-qnetworkrequest – Sebastian Lange Mar 13 '14 at 06:43

0 Answers0