1

I got the function addNew() that creates a form inside a backend component.

function addNew() {

    $route= JRoute::_( 'index.php?option=com_pelatol&task=insertyo');
    $html.='<form action="'.$route.'" method="GET" ><div><h3>Εισαγωγή Ακινήτων</h3>';
    //$html.='<input type="hidden" name="option" value="com_pelatol" />';
    //$html.='<input type="hidden" name="task" value="insertyo" />';

    $html.='<br/><span>Περιοχή</span></br><input type="text" name="perioxi" />';
    $html.='<br/><span>Εμβαδόν</span></br><input type="text" name="embado" />';
    $html.='<br/><span>Υπνοδομάτια</span></br><input type="text" name="ipnodomatia" />';
    $html.='<br/><span>Μπάνια</span></br><input type="text" name="mpania" />';
    $html.='<br/><span>Έτος</span></br><select>';
    $cYear=date("Y");


    for ($i=1950;$i<=$cYear;$i++) {

        $html.='<option value="'.$i.'">- '.$i.' -</option>';
    }
    $html.='</select>';
    $html.='<br/><span>Θέρμανση</span></br><input type="text" name="thermansi" />';
    $html.='<br/><span>Διαθέσιμο</span></br><input type="text" name="diathesimo" />';
    $html.='<br/><span>Οδός</span></br><input type="text" name="odos" />';
    $html.='<br/><span>Τιμή</span></br><input type="text" name="timi" />';
    $html.='</div><input type="submit"/></form>';
    echo $html;
}



function insertyo() {
   $session =& JFactory::getSession();
   var_dump($_GET);
   //$session->get( 'perioxi' )



}

When I click the submit button the URL I'm getting redirected is : administrator/index.php?perioxi=asdas&embado=asdasd&ipnodomatia=adasd&mpania=asdasdas&thermansi=asdasd&diathesimo=asdasd&odos=asdasd&timi=asd. It ignores the ?option=com_pelatol&task=insertyo statement of Jroute. I'm currently using a "hack" to achieve the desired output:

//$html.='<input type="hidden" name="option" value="com_pelatol" />';
//$html.='<input type="hidden" name="task" value="insertyo" />';

I'm sure there is another way. Am I missing something?

1
  • Why did you comment option and task hidden inputs? Apr 4, 2015 at 11:35

1 Answer 1

1

You should change method="GET" to method="POST".

HTML method Attribute

1
  • Why should i use post when i dont send sensitive data? Is it mandatory inside the component ??
    – IseNgaRt
    Mar 5, 2015 at 9:37

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.