1

Update

Folders are in

app\design\frontend\base\default\template\recipe_creation\index.php

\app\design\frontend\base\default\template\recipe_creation\data.php

Ie) In my .phtml i am posting something like :

<div class="main">
        <form action="<?php echo $this->getUrl('mymodule_customerpage/recipeCreation/data.php') ?>" method="post" id="form-validate" autocomplete="off">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            $(document).ready(function() {
                timePicker(10);
            });
        </script>
        <script>
        // timer code starts here --- 
        //var init2 = 50;
            var s;

            function timePicker(vr) {

                if (vr > 0)
                {
                    if (vr > 1) {
                          $('#timer').html('');


                    } else {

                          $('#timer').html('');
                    }
                    vr--;
                    s = setTimeout('timePicker(' + vr + ')', 1000);
                } else {
                    clearInterval(s);

                    //$.post('data.php',{txt_area:$('#rec_name').val(),txt_title:$('#rec_title').val()},function(r){ 
                    $.post('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>data.php',{txt_area:$('#rec_name').val(),txt_title:$('#rec_title').val()},function(r){                                                       
                         $('#upd_div').html("Last Updated: "+r);
                    $('#timer').html('Recipe Contents Saved.. ');
                    s = setTimeout('timePicker(' + 10 + ')', 5000);
                    return false;

                    });
                }
            }
        </script>

        <div class="content">
            <div class="heading">
                Recipe Creation Page-- Add Recipe.
            </div>
            <br/><br/>

            <div class="form-group2">  
                 <label>Recipe Name:</label>
                 <input type="text" name="rec_name" id="rec_name" class="form-group2" />
                 <br/><br/>
                 <div class="form-group">  
                    <label>Recipe title:</label>
                    <input type="text" name="rec_title" id="rec_title" class="form-group2" /> 
                </div>  
                 <br/><br/>
                 <br/><br/>
                <div id="timer_upd_dev">
                    <div id="timer">x Secs </div>
                    <div id="upd_div"> </div>
                </div>
            </div>  

        </div>
        </form>
    </div>
    <script>

Is the path given like below correct?

<form action="<?php echo $this->getUrl('mymodule_customerpage/recipeCreation/data.php') ?>" method="post" id="form-validate" autocomplete="off">

app\code\community\Mymodule\Customerpage\controllers\RecipeCreationController.php

class Mymodule_Customerpage_RecipeCreationController extends Mage_Core_Controller_Front_Action {
public function indexAction()
{
    $this->loadLayout();
    $this->renderLayout();
}
}  
1

try with Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); make sure you place the file with index.php

<div class="main">
   <form action="<?php echo $this->getUrl('mymodule_customerpage/recipeCreation/data.php') ?>" method="post" id="form-validate" autocomplete="off">
    $.post('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>myfile.php)
   </form>
</div>
  • I had tried renaming the index.phtml to index.php file before, but can i place .php files inside the app/design/../templates folder?? or should i move the folder containing index.php and data.php to another location – Sushivam Nov 7 '16 at 6:20
  • put in you main folder where is your index.php file – Qaisar Satti Nov 7 '16 at 6:23
  • i have updated the code...path of both the files..can that be given.. in $.post('data.php') how to give the path? – Sushivam Nov 7 '16 at 6:24
  • \app\design\frontend\base\default\template\recipe_creation\data.php put your file in same folder where your index.php mainfolder\data.php – Qaisar Satti Nov 7 '16 at 6:33
  • index.php and data.php is in same location folder @Qaisar ie \app\design\frontend\base\default\template\recipe_creation\<index.php, data.php> – Sushivam Nov 7 '16 at 6:35
0

First you need to set the block to phtml file like:

<block type="module/yourblock" name="anyname"template="foldername/myfile.phtml"/>

Then, post your from in phtml like:

<form action="<?php echo $this->getUrl("module/controller/action"); ?>" method="post">

Then, you get your field values in controller like:

$postData = Mage::app()->getRequest()->getPost();

then, pass your $postData variable to your block

$layout = $this->getLayout();

$block = $layout->getBlock('block_name');
$block->setPostdata($postData);
  • Hi @Rajan, i dont have any Blocks used in my module...in this case ill create an empty Block? – Sushivam Nov 7 '16 at 6:14
0

Yes that can be Done.

One of the method is to give the link of controller when the from gets submitted.

$this->getUrl('YourModule/YourController/YourAction');
  • Could you please check the updated code, i have tried as above...i get error – Sushivam Nov 7 '16 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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