In my php code
'user' => !empty($_POST['user']) ? substr($_POST['user'],0,10) : '',
In my template
<input type="text" maxlength="10" value='$context['user']'/>
With this I get the input to admit a maximum of 10 characters, and if someone cheats, and removes the maxlength, the php code will continue taking only 10 characters. In cases such as special characters, it counts as 2 characters, that is, if I put "ññññññññññ" in the database, it will only save "ñññññ" because that character counts as 2.
How could I make the php function (substr) count the special characters as 1 character and not as 2, or input count good special characters?