How to remove certain parameter in request getPost |
I want to update a data in a model, with parameter from user form request post. How can I filter that only certain field that can be updated by removing some parameters in getPost() ?
Pass all the getPost() data but set the allowed fields in the model. Everything else won’t be updated.
http://codeigniter.com/user_guide/models...your-model PHP Code: protected $allowedFields = ['name', 'email'];
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
If you're attempting to filter out fields that are defined in $allowedFields but you don't want an end user to somehow find out about them and then use them maliciously in a crafted request, you can just iterate over the data returned by getPost in a foreach statement, compare the key, and determine if it's allowed to stay.
PHP Code: foreach ($data as $key => $value) { |
Welcome Guest, Not a member yet? Register Sign In |