[eluser]Silviu[/eluser]
Hello,
I'm developing a small app and I want to do a check for a particular "description" field.
Basically, I want to translate that description (in several languages, using Google translate) but only if the user has changed it.
So, how do I check if the user has truly changed it? In my view, the best check is done against the value stored in the database.
But since the value stored in the database is escaped by default, how should I do the checking? Because if I do something like
Code:
if($this->input->post('description') != $database_description)
it will fail, since the user input is not equal with the database content (due to the above-mentioned automatic escaping).
Now, when I'm placing the description from the database in the form I use this code:
Code:
html_entity_decode(htmlspecialchars_decode(set_value('description', $item->description)))
otherwise, some characters will not be as the user entered them previously.
If I do the reverse when checking if the user has changed the field, will it do?
Code:
if(html_entity(htmlspecialchars($this->input->post('description'))) != $database_description)
I'm asking because I don't know what is the exact escaping mechanism of CI's database/AR class.