html - PHP $_POST doesn't take accents -


this question solved, check answer see solution


i'm trying add db text accented letters through html form submits post php page, problem accented letters converted unreadable characters.

i have form:

<form action="page.php" method="post">     <input type="textarea" id="text1" name="text1" />     <input type="submit" value="send" /> </form> 

and then, in page.php:

echo $_post['text1']; 

the problem if input àèìòù in textarea , submit form, output:

à èìòù 

my next step convert accented letters html entities htmlentities($_post['text1'] need $_post give me correct letters.

note: in page head have

<meta http-equiv = "content-type" content = "text/html; charset=utf-8" /> 

how can fix this?

edit

i tried with

<form action="page.php" method="post" accept-charset="utf-8">     <input type="textarea" id="text1" name="text1" />     <input type="submit" value="send" /> </form> 

and didn't solve it

edit 2

also tried adding

<meta charset='utf-8'> 

to document's head, , doesn't work

edit 3

i tried setting charset utf-8 on second page too, and

echo $_post['text1']; 

displayed correct result.

i saw problem whe use htmlentities, code

echo htmlentities($_post['text1']); 

i

&atilde;&nbsp;&atilde;&uml;&atilde;&not;&atilde;&sup2;&atilde;&sup1;  

which outputs

à èìòù  

even if set charset in meta-tags , header too. know how can solve it?

i'm going go other way - add php code <?php header("content-type: text/html; charset=utf-8"); ?>. saves having meta tags (that browsers casually ignore...)

from encoding representation provided, php echoing utf-8 encoded string, while browser assuming output iso-8859-1. setting header make all browsers understand utf-8 expected, provided had under accept-encoding. if didn't, they'll barf, know of 1 "modern" browser doesn't, , 0.2% of market.

note need throw line first, before other output (or can output-buffer lot, makes life easier drains bit more memory)


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -