Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.