I\'m working on a multilingual site with CodeIgniter. There is a form that posts data to controller, but $_POST
is empty when I start to use Turkish characters
Since the comments are piling up and will probably get overlooked, I am going to post some more suggestions.
Readers please keep in mind this is dealing with $_POST data values and not display of data on a web page.
This user seems to have a similar problem:
Codeigniter seems to break $_POST of '£' character (Pound)
There is a report here on Bitbucket of similar:
https://bitbucket.org/ellislab/codeigniter-reactor/issue/214/problem-when-inserting-special-characters:
Removed link: EllisLabs has closed this repo to the public
Maybe adding this to your index.php will help (probably not):
ini_set('default_charset', 'UTF-8');
Double check and make sure you aren't running any validation or prepping rules on the field. Things like url_title()
will strip those characters.
Make sure the form tag has accept-charset:
<form method="post" action="" accept-charset="utf-8">
Then in the controller use utf8_decode() when fetching the posted values:
$value = utf8_decode($this->input->post('field_name'));
This isnt an answer, but you might want to take a look and see how everything is coming in.
foreach($_POST as $key => $val)
{
$post_data[$key] => $val;
}
print_r($post_data);
then try with CI's post
foreach($_POST as $key => $val)
{
$post_data[$key] => $this->input->post($key);
}
print_r($post_data);
If you don't want to use a previous PHP version in your MAMP instalation you can use:
$_REQUEST
To get the data instead of $_POST
$_REQUEST
is an associative array that by default contains the contents of $_GET
, $_POST
and $_COOKIE
.
More info: http://php.net/manual/en/reserved.variables.request.php
And that returns all the data that for some reason $_POST
is breaking !