0

This a a form with a field

<label for="sec1-prenom">Prénom<span class="requis">*</span></label>
<input type="text" name="sec1-prénom" class="required"/>

and here is the loop to get the values

foreach($_POST as $name => $value) {
$myval .= $name .' : '.$value ."\r\n"; }

when i do the loop to get the value, the "name" field is : prˢnom (garbage)

what i need to do to get the proper utf8 value ?


note, as DAVE said, my for value dont match the name value. question, why it's should. and in fact, i just looking for a proper way to get the value of the label filed, just as written in test with accent and spaces. How i can get that with the $_POST... i think i cannot !

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
menardmam
  • 9,860
  • 28
  • 85
  • 113
  • [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/) – deceze Mar 15 '13 at 14:26
  • 1
    or don't use utf-8 characters in field names especially since your lable for= doesn't match your input box name. – Dave Mar 15 '13 at 14:36
  • You might want to check for BOM (byte order mark), that could mess up extended ASCII characters at times, it has for me. – Funk Forty Niner Mar 15 '13 at 14:39
  • Why it's important to have the SAME name for both. How i can retreive the value of the label in a $_POST ? – menardmam Mar 15 '13 at 14:39
  • @menardmam actually, `Dave` said that ;) (since your lable for= doesn't match your input box name...) – Funk Forty Niner Mar 15 '13 at 14:44
  • @menardmam what "I" said was, you might have a `BOM` issue. I was faced with a similar problem in the past. I since started using `Notepad++` to edit and save my PHP files. Sometimes with and sometimes without the BOM, it depends on how your server is configured. – Funk Forty Niner Mar 15 '13 at 14:46
  • @menardmam UTF-8 can be encoded with or without the BOM. Sometimes if you encode `with` the BOM, you will get messed up characters in place of an extended character; i.e. `é, à, è` etc. – Funk Forty Niner Mar 15 '13 at 14:54
  • @menardmam If you don't have `Notepad++`, you can download it at the following URL http://notepad-plus-plus.org/ – Funk Forty Niner Mar 15 '13 at 14:58
  • Let's just "delete" that for="" label... and live happy ! – menardmam Mar 15 '13 at 15:09
  • NO notepad++ for me, i am a MAC person !... holy steve ! – menardmam Mar 15 '13 at 15:10
  • @menardmam I'm sure there are some good text editors out there for the MAC that will let you save in different formats. I kind of have a feeling that you have a `BOM` issue. – Funk Forty Niner Mar 15 '13 at 15:21

1 Answers1

0

i have found : $_POST empty on utf-8 characters

in short, the value is already encoded (garbage) so i have to decode it : utf8_decode()

Community
  • 1
  • 1
menardmam
  • 9,860
  • 28
  • 85
  • 113
  • What exactly is the value submitted as? Show us `bin2hex($name)`. – deceze Mar 15 '13 at 14:38
  • You shouldn't have to decode it. You need to find the root of the problem instead of `patching` it. – Funk Forty Niner Mar 15 '13 at 15:32
  • By any chance, does the word "Prénom" appear as "Prénom" or as "PrÀ¢nom" as you originally posted? This is important to know and will definitely tell me that if it does appear as "Prénom", you have a `BOM` issue. – Funk Forty Niner Mar 15 '13 at 15:43
  • @Fred You seem to have an unhealthy obsession with BOMs. If you could at least specify the exact problem instead of just repeating vague references... – deceze Mar 16 '13 at 08:34
  • @deceze 8 times out of 10, that's what the problem is. – Funk Forty Niner Mar 16 '13 at 13:14