Why does $_REQUEST work but not $_POST
-
I’m building an OOP plugin to create admin pages to be used by a Multisite superadmin that uses a custom table. It’s a simple routine. Pick a record from a dropdown list, then get all the field data and display a second form to edit those fields.
Since there seems to be no way to call a class method in the action = part of the form tag, I’ve written a function that uses action = ” so the page will call itself on submit. The method is POST
Here’s the logic:
if($_POST['form_two'] !== 'save_data' ){ global $wpdb ; //do a query, get some values create a form to // let the user select one from a dropdown echo '<form type="post" action="" id="select_one" name "select_one">'; // a foreach to populate and display the <select> element echo '<input type="hidden" name="form_two" id="form_two" value="save_data"/>'; echo '<input name="send_select" id="send_select" type="submit" value="Select Ad To Edit" />'; echo '</form>'; } else { // the code for the edit form }
Fails every time. But change _POST to $_REQUEST and it works perfectly. You get an ungainly URL when you use REQUEST, which seems a bit odd too, but it works great.
I just want to know why $_POST doesn’t get populated but $_REQUEST does. It took me a LONG LONG time to figure out this hack. I’ just like to gain a little knowlege for the effort.
Thanks,
Ed
- The topic ‘Why does $_REQUEST work but not $_POST’ is closed to new replies.