Save contact form data magento table

This tutorial explains how to create contact table for saving contact form data magento database. The following code create the contact_table in the magento database as show below.

$installer = $this;

$installer->startSetup();

$installer->run("

DROP TABLE IF EXISTS `{$this->getTable('contact_table')}`;
CREATE TABLE `{$this->getTable('contact_table')}` (
  `contact_id` int(11) unsigned NOT NULL auto_increment,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `name` varchar(25) NULL default '',
  `email` varchar(50) NULL default '',
  `telephone` varchar(50) NULL default '',
  `comment` varchar(250) NULL default '',
  PRIMARY KEY (`contact_id`),
  INDEX (contact_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

");

$installer->endSetup();

Share this Tutorial