views:

48

answers:

2

I have this form:

<form method="post" enctype="multipart/form-data" accept-charset="UTF-8">

But when I submit an é character, it turns it into é.

Why doesn't this work? Yes, the MySQL database has all the character-sets set up correctly. (Database, tables.) If I manually put it in the database with Navicat it shows up fine on the webpage.

Also, I have tried the metatag, setting the content-type header, without success.

A: 

Ensure you have set your connection collation to utf8:

SET NAMES utf8
aularon
Already doing this.
Angelo Geels
Is the form page utf-8 as well? Also, did you try another browser/machine?
aularon
I just tried Internet Explorer, same problem. Other users also experience this problem.
Angelo Geels
+1  A: 

In your HTML, add this meta tag:

 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

Also add this PHP header at top of the script:

 header("Content-Type: text/html;charset=UTF-8");

[EDIT]:

One more tip is to save the file as UTF-8 without BOM encoding. You can use Notepad++ or any decent editor to do that.

shamittomar
Have both, doesn't change anything.
Angelo Geels
Do you have the `header` at the top in the HTML page where the form is ?
shamittomar
Yes. *extra characters*
Angelo Geels
@angelo, what do you mean by *extra characters* ? Also, I have updated my answer.
shamittomar
@shamittomar, I did that because only "Yes" is a too short comment :)
Angelo Geels
Also, the database CAN contain the correct characters, and CAN return the correct characters, which the page can display correctly. It really is PHP that's not sending it correctly (or the browser)
Angelo Geels
So, did you save it with `UTF-8 without BOM` ?
shamittomar