I am creating an admin module and need to process the form, but I'm having trouble getting POST variables, and I'm just redirected to the control panel. The form is as follows:
<form name="notes" action="<?php echo Mage::helper("adminhtml")->getUrl("foo/index/processnotes/");?>" method="post"> <input type="hidden" name="another_form_key" value="<? echo $this->getFormKey(); ?>" />
I do this because secure keys are enabled for the administrator. This gives me the url:
foo/index/processnotes/key/4745f5fbb9c168778958d5d4a4c2c0ef/
In the controller, I have:
public function processnotesAction(){ $model = Mage::getModel('foo/process');
and in Package/foo/Model/Process.php
I hope that I can process the POST variables from my form here, but I don’t see what’s wrong and I’m just sent to the toolbar.
<?php class Package_foo_Model_Process extends Mage_Core_Model_Abstract { public function noteProcess() { $test = $_POST['myValue']; echo $test; } }
Update
After reading the answers, I wanted to add a bit more of what my real code is doing and how I use $ _POST. I created a simple example to just get a form for publishing, but realizing that there are probably a lot of things that I am doing wrong in Magento.
$query="INSERT INTO `notes_value` ( `color`, `the_id`, `the_value` ) VALUES "; $sku = $_POST['color']; array_pop($_POST); foreach ($_POST AS $key => $value) { $values[] = "('$sku', '$id', '$value')"; } $query .= implode(', ', $values) . ';';
Dream: I could $resource->getConnection('core_write');
actually insert this into the database, but felt less optimistic about how this happens.