davidz Posted June 14, 2007 Share Posted June 14, 2007 I have a form that is posting it data to PHP_SELF. This then gets processed and does it's thing. My question is that when I hit the submit button, I get all the data from my form but I also get one item from the Submit button itself. Can I make the submit button not include itself in the POST? Here is an example output of print_r($_POST) Array ( [ACPlatSearch] => -1 [ACDeedSearch] => -1 [ACUserInfo] => -1 [ACPropertySearch] => -1 [ACStatsTotalSales] => -1 [savePermissions] => Save ) The last element is the submit button, the other ones are checkboxes. I don't want that last one. So is there a simple way to not include it or do I need to loop through the array and remove it manually? I need the rest of the array intact for further processing with array functions. Thanks! David Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/ Share on other sites More sharing options...
akitchin Posted June 14, 2007 Share Posted June 14, 2007 if you make sure to always name your submit buttons the same thing, you can simply unset() it prior to operating on the $_POST array. Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/#findComment-274973 Share on other sites More sharing options...
davidz Posted June 14, 2007 Author Share Posted June 14, 2007 For example: unset($_POST['SavePermissions']); Correct? Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/#findComment-274976 Share on other sites More sharing options...
akitchin Posted June 14, 2007 Share Posted June 14, 2007 exactly. give it a shot. Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/#findComment-274983 Share on other sites More sharing options...
davidz Posted June 14, 2007 Author Share Posted June 14, 2007 Works Perfectly. So as to the other question, there is no way to tell it to not be part of the post? I kinda figured that's how it would be. Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/#findComment-274991 Share on other sites More sharing options...
akitchin Posted June 14, 2007 Share Posted June 14, 2007 no - it's an input like all others. every input element is inserted into the POST data, you simply have to remove it manually. Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/#findComment-274992 Share on other sites More sharing options...
kenrbnsn Posted June 14, 2007 Share Posted June 14, 2007 If you don't give the submit button a name, it won't be included in the $_POST array. Ken Quote Link to comment https://forums.phpfreaks.com/topic/55648-solved-removing-an-element-from-the-post-array/#findComment-274996 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.