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 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.

Write a comment ...
Post comment
Cancel
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.

Write a comment ...
Post comment
Cancel
profile justre 5th September 2025

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

Write a comment ...
Post comment
Cancel
profile justre 19th August 2025

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

Write a comment ...
Post comment
Cancel
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.

Write a comment ...
Post comment
Cancel
profile justre 19th August 2025

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

Write a comment ...
Post comment
Cancel
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.

Write a comment ...
Post comment
Cancel
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.

Write a comment ...
Post comment
Cancel
profile anna 14th July 2025

Retro Bowl is a retro-style American football game developed by New Star Games. The game offers a classic football experience with pixel graphics, fun sounds, and simple yet engaging gameplay.

Write a comment ...
Post comment
Cancel
profile Naeem 21st May 2025

Thanks for your time so much for your impressive and amazing guide. I will not be reluctant to endorse your web sites to any individual who should receive direction on this problem. coincheckup

Write a comment ...
Post comment
Cancel
profile Arthur 6th May 2025

Color Block Jam encourages players to experiment with different block arrangements.

Write a comment ...
Post comment
Cancel
profile rick 22nd April 2025

The Crazy Cattle 3D three maps are more than just eye candy—they fundamentally change how you play

Arthur
06-05-2025 00:00

<a href="https://colorblockjamonline.github.io">color block jam</a>’s intuitive controls make it accessible for all ages.

Arthur
06-05-2025 00:00

[url=https://colorblockjamonline.github.io]color block jam[/url] offers a satisfying burst when blocks reach their matching doors.

Write a comment ...
Post comment
Cancel
profile Naeem 17th April 2025

Cheers for this excellent. I was wondering whether you were planning of publishing similar posts to this. .Keep up the excellent articles! sweet bonanza

Write a comment ...
Post comment
Cancel
profile Naeem 12th April 2025

You undoubtedly ensure it is look simple along with your business presentation however i come across this kind of topic being truly an issue that I think I might never recognize. It appears also complex and extremely wide personally. I will be impatient for your next article, I am going to try to get the hang of it! Mantap168

Write a comment ...
Post comment
Cancel
profile Beatrix 22nd March 2025

The city maze is crazy! Escape Road City is among my favorite vehicle games since it requires you to try to survive while dodging all the obstacles.

mrsumit
25-03-2025 00:00

CERT-In audit penetration testing is crucial for organizations to comply with security regulations and protect against cyber threats. It ensures systems are tested for vulnerabilities and secured against potential breaches. ae.penetolabs offers expert CERT-In audit <a href="https://ae.penetolabs.com/cert-in-audit-services/">CERT-In Audit Penetration Testing Service</a> penetration testing services, helping businesses identify security gaps, achieve compliance, and strengthen their defense mechanisms. Their in-depth assessments follow industry best practices, ensuring data protection and regulatory adherence. Partnering with a CERT-In empanelled service provider enhances cybersecurity resilience and safeguards critical business assets.

Write a comment ...
Post comment
Cancel

Post Your Message

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