1

I'm having a weird issue with a form, if a send any spanish character (á, é, í, ñ, etc...) in the form, it appears as a blank string in the $_POST array.

This is the form:

<form action="<?php echo site_url("home/register"); ?>" method="post">
    <div class="row">
        <div class="col-md-4 col-md-offset-4">
            <input type="text" placeholder="Nombre" name="user[name]"  class="form-control"/>
        </div>
        <div class="space"></div>
        <div class="col-md-4 col-md-offset-4">
            <input type="text" placeholder="Apellido" name="user[lastname]"  class="form-control"/>
        </div>
        <div class="space"></div>
        <div class="col-md-4 col-md-offset-4">
            <input type="text" placeholder="E-Mail" name="user[email]" class="form-control"/>
        </div>
        <div class="space"></div>
        <div class="col-md-4 col-md-offset-4">
            <input type="password" placeholder="Clave" name="user[password]"  class="form-control"/>
        </div>
        <div class="space"></div>
        <div class="col-md-4 col-md-offset-4">
            <input type="password" placeholder="Confirmar Clave" name="user[password_confirmation]"  class="form-control"/>
        </div>
        <div class="space"></div>
        <div class="col-md-4 col-md-offset-4 text-center">
            <input type="submit" value="Registrar" class="btn btn-primary"/>
        </div>
    </div>
</form>

I already tried without the "user[]".

I have never had this problem before, i know about the enconding problems but just not sending the value is completely new for me.

I google a lot, but i think i'm making the wrong search because i cant find anything similar.

I'm using PHP 5.5.9, Apache 2.4.7 and using Codeigniter 2, i have worked with this config many times before and, again, never saw this problem before.

Here a test:

If i send the data without spanish characters, there is no problem:

array(1) {
  ["user"]=>
  array(5) {
    ["name"]=>
    string(4) "Jose"
    ["lastname"]=>
    string(5) "Lopez"
    ["email"]=>
    string(7) "t@t.com"
    ["password"]=>
    string(1) "a"
    ["password_confirmation"]=>
    string(1) "b"
  }
}

if i change, for example, Jose with José, i get:

array(1) {
  ["user"]=>
  array(5) {
    ["name"]=>
    string(0) ""
    ["lastname"]=>
    string(5) "Lopez"
    ["email"]=>
    string(7) "t@t.com"
    ["password"]=>
    string(1) "a"
    ["password_confirmation"]=>
    string(1) "b"
  }
}
Choxx
  • 945
  • 1
  • 24
  • 46
Vertig0
  • 623
  • 3
  • 15

1 Answers1

1

Add this line in your head,

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  • While this may answer the question it’s always a good idea to put some text in your answer to explain what you're doing. Read [how to write a good answer](http://stackoverflow.com/help/how-to-answer). – Jørgen R Apr 10 '15 at 07:17
  • Yeah, this solve the problem. But i still dont know what happened, is not the first time i dont put that tag but the first time i have this problem. – Vertig0 Apr 10 '15 at 13:21