Save contact us queries in database magento and view it's listing in admin panel

Save contact us queries in database magento and view it's listing in admin panel

 To save contact us queries we need to override the Contacts_IndexController  and put the insert queries by overriding Post function. Also we need to create a module to show the customer queries listing in Admin  Panel and create a table with relevant field to save the contact us query.

 Below is the code to override Contacts_IndexController in config.xml file.
 
app/code/local/Letsknowit/Contactus/etc/config.xml
 
 
<config>
    <modules>
        <Letsknowit_Contactus>
            <version>0.1.0</version>
        </Letsknowit_Contactus>
    </modules>
<frontend>
       <routers>
            <contacts>
                <args>
                    <modules>
                        <Letsknowit_Contactus before="Mage_Contacts">Letsknowit_Contactus</Letsknowit_Contactus>
                    </modules>
                </args>
            </contacts>
        </routers>
       
    </frontend>
</config>
 
To create the table and fields to save the data we have to write a script at
below path
 
app/code/local/Letsknowit/Contactus/sql/contactus_setup/mysql4-install-0.1.0
 
<?php
 
$installer = $this;
 
$installer->startSetup();
 
$installer->run("
 
-- DROP TABLE IF EXISTS {$this->getTable('contactus')};
CREATE TABLE {$this->getTable('contactus')} (
  `contactus_id` int(11) unsigned NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `telephone` varchar(255) NOT NULL default '',
  `comment` text NOT NULL default '',
  `status` smallint(6) NOT NULL default '0',
  `created_time` datetime NULL,
  `update_time` datetime NULL,
  PRIMARY KEY (`contactus_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
    ");
 
$installer->endSetup(); 
 
?>
 
Now in app/code/local/Letsknowit/Contactus/controllers/IndexController.php
we will put our insert query.
 
<?php
require_once 'Mage/Contacts/controllers/IndexController.php';
class Letsknowit_Contactus_IndexController extends Mage_Contacts_IndexController
{
    
 
    public function postAction()
    {
       $post = $this->getRequest()->getPost();
       
 
       /* code to save query , you can write our insert query here*/
       if ( $post ) {
          
                               $model = Mage::getModel('contactus/contactus');
$model->setData($post);
$model->save();
 
            }
     
 
    }
?>
 
 

0   0
Aditya Singh
profile 17th December 2025

Can you become the richest person playing grow a garden? Plant, harvest, and sell your produce for money. Each yield corresponds to a different amount of money.

profile Cheetah 13th November 2025

Shop stylish sweatshirts for every season. Stay warm and trendy with our cozy collection for men in Pakistan.

profile Servis 12th November 2025

Discover the latest collection of branded shoes for men at Servis. Step up your style game with our exclusive range of footwear.

profile Brisk 11th November 2025

Shop the best men’s polo shirts offering style, comfort, and durability. Perfect choice for work, travel, or any casual day out in all seasons.

profile Grow 11th November 2025

Enjoy healthy pancake mix in Pakistan made with natural grains and ingredients. The perfect choice for a tasty and nourishing morning meal.

profile Adoro 10th November 2025

Using our unique selection of men loafers find the ideal fashion and comfort. These adaptable shoes provide trendy style and classic beauty, making them perfect for every occasion. Get outstanding quality and affordable costs by shopping now.

profile Shop 10th November 2025

Upgrade your wardrobe with ECS' simple trouser design. Made with high-quality materials, our trousers offer a comfortable and stylish fit for any occasion. So, grab your trousers today.

profile Inam 19th September 2025

This is exactly where a source code review service becomes so valuable. Having a second, expert set of eyes look over custom modules like this can catch security vulnerabilities that might not be obvious at first glance. For instance, in creating a new table and handling form submissions, there are risks of things like SQL injection or cross-site scripting.

profile 8th September 2025

I bring you the experience basket random is very interesting online game. I played this game with my friends had a lot of fun playing.

profile justre 5th September 2025

Brat Generator makes it easy to design custom Charli XCX brat cover style images in seconds, free and online.

profile justre 19th August 2025

Sprunki Coloring Pages – Explore free printable designs and bring your favorite characters to life with colors.

profile justre 19th August 2025

If you have old family photos that are faded or damaged, I recently found a really useful tool: Restore Old Photos. It uses AI to restore and colorize old pictures — super easy and the results are amazing.

profile justre 19th August 2025

HEIC to JPG – Convert your HEIC photos to high-quality JPG images online, fast and free.

profile justre 19th August 2025

Try Flux Krea now and see your ideas transformed! Whether you want inspiration or precision, Flux Krea delivers exceptional results for every creative and technical need.

profile justre 19th August 2025

Kontext Dev lets you edit images with AI precision and local control. Try it free online and unlock more features with credits.

Please rotate your device

We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site