Welcome Guest, Not a member yet? Register   Sign In
Input.php library cleaning value from $_POST, CI3.1.13
#1
Bug 
(This post was last modified: 08-17-2023, 11:45 PM by surjitkmr.)

My html form have these 2 dropdown fields with same name (layout[]), When im submitting the form, im not getting value in controller. I have debug the issue and reach to Input.php. in this script post method not have 'layout' field value in $_POST, but when i print $_POST in CI_Input -> _contructor then it have 'layout' field value.
I have seen this issue only for fields which have name 'layout[]'.
earlier it was working with php5.6 and ci3.1.12 but when we upgrade to php8.1 and ci3.1.13 it stop working.
any one can help me to fix this? thanks in advance. 

<form action="https://10.60.51.246:81/app/dashboard/settings" class="form-horizontal" method="post"><div style="display:none">

<input type="hidden" name="ci_csrf_token" value="8d1d35c39ea2aa18588c3ccb9a7f3985">

<select name="layout[]" id="layout.0">
<option value="0">None</option>
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>

<select name="layout[]" id="layout.1">
<option value="0">None</option>
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form>
Reply
#2

Hello, I think this issue might be related to the way CodeIgniter handles form inputs with square brackets in their names, as it uses them to parse the input as an array. However, square brackets in input names can sometimes cause conflicts or unexpected behavior. If you are comfortable modifying the framework's core files, you can try updating the system/core/Input.php file to handle the array input with square brackets correctly. However, note that modifying core files is generally not recommended as it can cause issues during future updates or upgrades of CodeIgniter.
Reply
#3

Hello,

It seems like you’re encountering an issue where the layout[] field values are not being captured in the $_POST array after upgrading to PHP 8.1 and CI3.1.13. This could be due to several reasons, including changes in how PHP handles form data or updates in the CodeIgniter framework that affect the Input.php library.
Ensure that all your code is compatible with PHP 8.1. There have been many changes and deprecations from PHP 5.6 to 8.1, which might affect how arrays are handled.
Look through the changelog for CodeIgniter versions 3.1.12 and 3.1.13 to see if there were any changes made to the Input.php library that could have affected the handling of $_POST data.
Use PHP’s var_dump() or print_r() functions to print out the contents of $_POST at various points in your script to see where the data might be getting lost.
As a workaround, you might consider using the php://input stream to parse the raw data from the request manually. This is especially useful if the content type of the request is not application/x-www-form-urlencoded or multipart/form-data.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB