I have created the module with a form in front end on submit it send email and its working fine, now i also want to save the current form data to a Database table and keep the email functionality too that is working fine right now:
Here is the form action:
<form id="simple_contact_form" name="simple_contact_form" action="<?php echo $this->getUrl('reviews/email/sendemail') ?>" method="post"> And here the function to in my module to send email:
<?php class OptFirst_ReviewMyCompany_EmailController extends Mage_Core_Controller_Front_Action { public function sendemailAction() { $params = $this->getRequest()->getParams(); $mail = Mage::getModel('core/email'); $body = '<p>Hello,</p> <p>A New CLient Review Is Received:</p> <p><b>Name:</b> ' . ($params['name']) . '<br> <p><b>Email:</b> ' . ($params['email']) . '<br> <b>Comments:</b> ' . ($params['comment']) . '</p>'; $mail = new Zend_Mail(); $mail->setBodyHtml($body); $mail->setFrom($params['email'], $params['name']); $mail->addTo('[email protected]'); $mail->setSubject('Review Form'); try { $mail->send(); Mage::getSingleton('core/session')->addSuccess('Message has been Sent Successfully.'); $this->_redirect('reviews/'); } catch (exception $ex) { Mage::getSingleton('core/session')->addError('Unable to send email. Sample of a custom notification error from Contact Us Form.'); } $connectionresource = Mage::getSingleton('core/resource'); $connectionWrite = $connectionresource->getConnection('core_write'); $table = 'optfirst_contacts'; $query = "insert into ".$table." " . "(name,email,comments) values " . "(:name, :email, :comments)"; $binds = array( 'name' => 'values', 'email' => 'values', 'comment' => 'values', ); $connectionWrite->query($query, $binds); $this->_redirect('reviews/'); } } created the query to save data to DB table but it throws an error:
Invalid parameter number: parameter was not defined What is wrong going on here any help?