0

\app\code\local\Svi\Form\controllers\IndexController.php

<?php
Class Svi_Form_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){
        $layout =$this->loadLayout();
        $this->renderLayout();
    }

    public function postAction()
    {
        $data = $this->getRequest()->getPost();
        $model = Mage::getModel('form/form')->setData($data);
        try {
            $insertId = $model->save()->getId();
            echo "Data successfully inserted. Insert ID: ".$insertId;
        }
        catch (Exception $e){
            echo $e->getMessage();
        }

    }

}
?>

From $model, I found following array......

Svi_Form_Model_Form Object ( [_eventPrefix:protected] => core_abstract [_eventObject:protected] => object [_resourceName:protected] => form/form [_resource:protected] => [_resourceCollectionName:protected] => form/form_collection [_cacheTag:protected] => [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] => Array ( [fname] => amit [lname] => kushwaha [mothername] => Sushma [fathername] => bholaNath [mobile] => 8858234949 ) [_hasDataChanges:protected] => 1 [_origData:protected] => [_idFieldName:protected] => [_isDeleted:protected] => [_oldFieldsMap:protected] => Array ( ) [_syncFieldsMap:protected] => Array ( ) )

I found my table blank but it gave me message 'successful inserted'. What to do? please help me...

1 Answer 1

0

Try this

Replace this

 $insertId = $model->save()->getId();

with this

 $model->save();
 $insertId =  $model->getId();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.