1

I'm trying to send user name with libgdx's input textfield. It works fine with normal characters, i can send it to php and save it into database. But when i try special turkish characters like "ö,ş,ğ,ç,ü" etc. it doesn't send those characters and the characters after them. And additionaly special caharacters can be seen in textfield, but not sending them to php file.

I saw a post about this problem, here, and i've updated libgdx version to the latest stable one. But still i'm having the same problem.

The code i'm using is below:

HttpRequest request = new HttpRequest(HttpMethods.POST);
request.setUrl("http://xxxxx.com/create_usr.php");
request.setContent("name=" + name);

Do i have to add something more to this http code for sending those characters?

Additionally i've seen some extra code on net, i don't know what they do but i've added them before seturl, but didn't work:

request.setHeader("Accept-Charset", "utf-8");
request.setHeader("Content-Type", "application/x-www-form-urlencoded");

SOLVED:

I've changed the httprequest part with the code below and it worked. I've also changed the post method to get:

HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("name", name);
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl("http://xxxxx.com/create_usr.php"");
request.setContent(HttpParametersUtils.convertHttpParameters(parameters));
Community
  • 1
  • 1
yavona
  • 107
  • 1
  • 10

1 Answers1

0

Try calling your URL from the web browser to make sure is the problem in libgdx app or in php. It may happen that your database (field) is in UTF8, but your mySql connection isn't so it's worth checking out.

Also, I'm not sure but maybe you must encode parameter value and decode it on php side.

http://php.net/manual/en/function.urldecode.php

MilanG
  • 6,994
  • 2
  • 35
  • 64
  • Thanks MilanG, with web browser it works perfect. It's all about using wrong codes i guess. I've solved this with new code lines and pasted the solution above. Hope it helps someone else :) – yavona Jan 28 '15 at 14:15