palash4003 Posted July 15, 2011 Share Posted July 15, 2011 I'm trying to have a lot of fields data entry from user and send to SQL. It looks like it's picking up some entries and not picking up some others. <tr> <td align="left" valign="top">House Description <span class="starmark">*</span></td> <td align="left" valign="top">:</td> <td align="left" valign="top"><textarea name="house_description" cols="50" rows="10" id="house_description"><?php echo str_replace("<br>", "\n", $house_description);?></textarea></td> </tr> <tr> <td align="left" valign="top"> Restriction <span class="starmark">*</span></td> <td align="left" valign="top">:</td> <td align="left" valign="top"><textarea name="restriction" cols="50" rows="5" id="restriction"><?php echo $restriction;?></textarea></td> </tr> Over here: there are two fields - house_description and restriction. It is picking up restriction, as I put, but not picking up the house_restriction. PHP code used here: foreach($_POST as $key => $value) { //echo '<pre>'; print_r($_POST); print_r($_GET); echo '</pre>'; $$key = trim($value); $pass_string .= '&'. $key . '=' . trim($value); } I tried the print_r($_POST) and found: [square_feet] => $1050 [house_description] => [restriction] => Pets welcome, gardening place [available_timeh] => Aug, 2011 You may see all other 3 fields picked up it's data, but not the house_description. Any help is greatly appreciated. Thanks, ~A Quote Link to comment https://forums.phpfreaks.com/topic/242072-php-code-not-picking-up-textarea-field-values/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 15, 2011 Share Posted July 15, 2011 You probably have another form field later in the form using that same name="...." (the last one wins.) What's your entire form? Quote Link to comment https://forums.phpfreaks.com/topic/242072-php-code-not-picking-up-textarea-field-values/#findComment-1243147 Share on other sites More sharing options...
palash4003 Posted July 15, 2011 Author Share Posted July 15, 2011 Thanks PFMaBiSmAd Guru for your prompt reply. It does work. You are great! But, here is new issue: I'm sharing same data structure for different types of input and it needs to share the form. How to co-relate the html input name vs. phpname vs. data structure field? For example, I need to use description field for multiple types and I do not want to have multiple field for each type in my SQL data structure. Let's go for an example: I have type: a, b, c Each need description field. Each time user name choose among type (a,b,c) and the input description field from PHP code should send SQL type (a,b,c) and description. I have a code to choose, which one user picking among (a,b,c) and then the form will show description field. Can I use the same description or do I need different description and during SQL insert, I can use the corresponding variables? Quote Link to comment https://forums.phpfreaks.com/topic/242072-php-code-not-picking-up-textarea-field-values/#findComment-1243165 Share on other sites More sharing options...
palash4003 Posted July 15, 2011 Author Share Posted July 15, 2011 Thanks PFMaBiSmAd Guru. I figured out rest, but that was the clue of sharing the same form name. You are really a guru indeed! I truly appreciate your help!! Long live phpfreaks! Quote Link to comment https://forums.phpfreaks.com/topic/242072-php-code-not-picking-up-textarea-field-values/#findComment-1243305 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.