dink87522 Posted December 20, 2010 Share Posted December 20, 2010 $amountBoxName = "amount".$id; // Constructs the name of the input field $amountToPay = strip_tags($_POST["$amountBoxName"]); $amountBoxName then goes to 'amount22' says, however $amountToPay is then showing also as 'amount22', not getting the value of the text field whose name/id is amount22 on the previous page. How do I do this? I tried having " around the $amountBoxName, ' and no quotes although still can't get it working. Quote Link to comment https://forums.phpfreaks.com/topic/222250-how-to-use-_post-with-the-post-name-being-a-variable/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 20, 2010 Share Posted December 20, 2010 $amountToPay is then showing also as 'amount22' Than that is what is in $_POST['amount22'] or you have some other code you are not showing that is setting $amountToPay to 'amount22' directly. Have you used print_r() on the $_POST array so that you know what you are getting - echo '<pre>',print_r($_POST,true),'</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/222250-how-to-use-_post-with-the-post-name-being-a-variable/#findComment-1149692 Share on other sites More sharing options...
dink87522 Posted December 20, 2010 Author Share Posted December 20, 2010 print_r: [payAmount22] => -3885 That is printed right above my code above, nothing else is changing it after that. Quote Link to comment https://forums.phpfreaks.com/topic/222250-how-to-use-_post-with-the-post-name-being-a-variable/#findComment-1149693 Share on other sites More sharing options...
litebearer Posted December 20, 2010 Share Posted December 20, 2010 long day, crazy ideas floating in head, here is one of them (TOTALLY untested - probably TOTALLY un-thought through... name="amount[<?PHP echo $id; ?>]" /* this is for naming the form field */ $amountToPay = $_POST['amount[$id]']; /* this is for getting the form field value */ Quote Link to comment https://forums.phpfreaks.com/topic/222250-how-to-use-_post-with-the-post-name-being-a-variable/#findComment-1149694 Share on other sites More sharing options...
dink87522 Posted December 20, 2010 Author Share Posted December 20, 2010 Thanks, that works and will do what I need. Quote Link to comment https://forums.phpfreaks.com/topic/222250-how-to-use-_post-with-the-post-name-being-a-variable/#findComment-1149695 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.