1

How Can insert front end form value in Magento 1.9xxx, My form field is

<form action="#" method="post" name="form1">
        <table width="25%" border="0">
            <tr> 
                <td>User Name</td>
                <td><input type="text" name="username"></td>
            </tr>
            <tr> 
                <td>Password</td>
                <td><input type="text" name="password"></td>
            </tr>
            <tr> 
                <td>Email</td>
                <td><input type="text" name="email"></td>
            </tr>
            <tr> 
                <td></td>
                <td><input type="submit" name="Submit" value="Save"></td>
            </tr>
        </table>
</form>
sv3n
  • 11,657
  • 7
  • 40
  • 73
Fahim
  • 19
  • 3

1 Answers1

0

Please find the Below files to Your Requirement.

File Path : app\code\local\Clutch\Club\etc\config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Clutch_Club>
      <version>0.1.0</version>
    </Clutch_Club>
  </modules>
  <frontend>
    <routers>
      <club>
        <use>standard</use>
          <args>
            <module>Clutch_Club</module>
            <frontName>club</frontName>
          </args>
      </club>
    </routers>
        <layout>
          <updates>
            <club>
              <file>club.xml</file>
            </club>
          </updates>
        </layout>
  </frontend>
  <global>
    <helpers>
      <club>
        <class>Clutch_Club_Helper</class>
      </club>
    </helpers>
    <blocks>
      <club>
        <class>Clutch_Club_Block</class>
      </club>
    </blocks>
    <models>
      <club>
        <class>Clutch_Club_Model</class>
        <resourceModel>club_mysql4</resourceModel>
      </club>
      <club_mysql4>
        <class>Clutch_Club_Model_Mysql4</class>
        <entities>        
              <userinfo>
                <table>userinfo</table>
              </userinfo>
        </entities>
      </club_mysql4>
    </models>
    <resources>
      <club_setup>
        <setup>
          <module>Clutch_Club</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </club_setup>
      <club_write>
        <connection>
          <use>core_write</use>
        </connection>
      </club_write>
      <club_read>
        <connection>
          <use>core_read</use>
        </connection>
      </club_read>
    </resources>
  </global>
  <admin>
    <routers>
      <club>
        <use>admin</use>
        <args>
          <module>Clutch_Club</module>
          <frontName>admin_club</frontName>
        </args>
      </club>
    </routers>
  </admin>
  <adminhtml>
    <menu>
      <club module="club">
        <title>Club</title>
        <sort_order>100</sort_order>
        <children>
          <userinfo module="club">
            <title>Manage Userinfo</title>
            <sort_order>0</sort_order>
            <action>admin_club/adminhtml_userinfo</action>
          </userinfo>
        </children>
      </club>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <club translate="title" module="club">
              <title>Club</title>
              <sort_order>1000</sort_order>
              <children>
          <userinfo translate="title">
            <title>Manage Userinfo</title>
            <sort_order>0</sort_order>
          </userinfo>
              </children>
            </club>
          </children>
        </admin>
      </resources>
    </acl>
    <layout>
      <updates>
        <club>
          <file>club.xml</file>
        </club>
      </updates>
    </layout>
  </adminhtml>
</config>  

File Path : app\code\local\Clutch\Club\sql\club_setup\mysql4-install-0.1.0.php

<?php
$installer = $this;
$installer->startSetup();
$sql=<<<SQLTEXT
create table userinfo(id int not null auto_increment, name varchar(100), password varchar(100), email varchar(100), primary key(id));

SQLTEXT;

$installer->run($sql);
//demo 
//Mage::getModel('core/url_rewrite')->setId(null);
//demo 
$installer->endSetup();

File Path : app\code\local\Clutch\Club\controllers\IndexController.php

<?php
class Clutch_Club_IndexController extends Mage_Core_Controller_Front_Action{
    public function IndexAction() {

      $this->loadLayout();   
      $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename"));
            $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
      $breadcrumbs->addCrumb("home", array(
                "label" => $this->__("Home Page"),
                "title" => $this->__("Home Page"),
                "link"  => Mage::getBaseUrl()
           ));

      $breadcrumbs->addCrumb("titlename", array(
                "label" => $this->__("Titlename"),
                "title" => $this->__("Titlename")
           ));

      $this->renderLayout(); 

    }
    public function SaveAction() {

      $url = Mage::getBaseUrl().'club';

      $post_data=$this->getRequest()->getPost();
      //print_r($post_data);
      //exit;
      $pswd = md5(post_data['password']);
      $collection = Mage::getModel('club/userinfo');

      $collection->setName($post_data['username']);
      $collection->setPassword($pswd);
      $collection->setEmail($post_data['email']);
      $collection->save();
      //$this->_redirect("http://192.168.1.205:8012/magento1936/club");
      Mage::app()->getFrontController()->getResponse()->setRedirect($url);
    }
}

File Path: app\code\local\Clutch\Club\Model\Mysql4\Userinfo\Collection.php

<?php
    class Clutch_Club_Model_Mysql4_Userinfo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
    {

        public function _construct(){
            $this->_init("club/userinfo");
        }



    }

File Path: app\code\local\Clutch\Club\Model\Mysql4\Userinfo.php

<?php
class Clutch_Club_Model_Mysql4_Userinfo extends Mage_Core_Model_Mysql4_Abstract
{
    protected function _construct()
    {
        $this->_init("club/userinfo", "id");
    }
}

File Path: app\code\local\Clutch\Club\Model\Userinfo.php

<?php

class Clutch_Club_Model_Userinfo extends Mage_Core_Model_Abstract
{
    protected function _construct(){

       $this->_init("club/userinfo");

    }

}

File Path :app\design\frontend\rwd\default\layout\club.xml

<?xml version="1.0"?>   
<layout version="0.1.0">   
  <club_index_index>   
    <reference name="root">   
      <action method="setTemplate"><template>page/2columns-right.phtml</template></action>   
    </reference>
    <reference name="right">   
      <block type="club/right" name="club_right" template="club/right.phtml"/>   
    </reference>   
    <reference name="content">   
      <block type="club/index" name="club_index" template="club/index.phtml"/>   
    </reference>   
  </club_index_index>   
</layout>   




File Path : app\design\frontend\rwd\default\template\club\index.phtml


<form action="<?php echo "<?php echo "Base Url"?>club/index/save"?>" method="POST" name="form1">
        <table width="25%" border="0">
            <tr> 
                <td>User Name</td>
                <td><input type="text" name="username"></td>
            </tr>
            <tr> 
                <td>Password</td>
                <td><input type="password" name="password"></td>
            </tr>
            <tr> 
                <td>Email</td>
                <td><input type="text" name="email"></td>
            </tr>
            <tr> 
                <td></td>
                <td><input type="submit" name="Submit" value="Save"></td>
            </tr>
        </table>
</form>

File Path :app\etc\modules\Clutch_Club.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Clutch_Club>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Clutch_Club>
  </modules>
</config>
Learing_Coder
  • 1,007
  • 1
  • 12
  • 27