Jump to content

[SOLVED] Disappearing $_POST vars from array???


amites

Recommended Posts

Hello,

 

I'm running into a strange one, I have a form item that looks like:

 

<input type="text" name="property_taxes_monthly_expenses[]" id="property_taxes_monthly_expenses" class="expense expenses money form_fields" tabindex="1" value="" style="width: 120px;"/>

 

generated by:

    <td> $ <input type="text" style="width: 120px;"
            value="<?php if(isset($_POST['property_taxes_monthly_expenses[]'])) echo $_POST['property_taxes_monthly_expenses[]']; ?>"
            tabindex="1" class="expense expenses money form_fields"
            id="property_taxes_monthly_expenses<?php if($num > 0) echo $num;?>"
            name="property_taxes_monthly_expenses[]"/></td>

 

the bug:

the value placed into this form field is not being accepted, I've gone so far as to submit the value manually through a firefox extension, nada

this form has over 100 fields and this is 1 of 2 that don't hold their value when I print_r($_POST)

 

this is being built inside the code igniter framework though I have checked the $_POST var before anything is initiated and it comes back blank every time, if I rename the vars it works some of the time, setup the same way as 16 other array vars and I'm stumped

 

any ideas?

I think this is your problem, you have:

 

<?php
if(isset($_POST['property_taxes_monthly_expenses[]']))
echo $_POST['property_taxes_monthly_expenses[]'];
?>

 

You need:

 

<?php
// I'm guessing at indexes - assuming that you only have 1 HTML 
//   input named "property_taxes_monthly_expenses[]"
if(isset($_POST['property_taxes_monthly_expenses'][0]))
echo $_POST['property_taxes_monthly_expenses'][0];
?>

 

If you don't want to deal with a multidimensional array than just change the HTML input's name to "property_taxes_monthly_expenses" without the brackets.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.