Using $_Get Instead Of $_Post

I want to use $_GET method instead of $_POST in my controller and view.How to do that.I tried interchanging them but it did not work for me…

How are you sending the data to the server?

can you paste your code please

Actually the problem is I have my get working ,but it discloses the table name and fields associated with it.So,how to deal with that scenario?

can’t help you unless you post some code

For your convenience I am posting here a snippet of view page:

<?php /** @var BootActiveForm $form */

$form = $this->beginWidget(‘bootstrap.widgets.TbActiveForm’, array(

	'id'=&gt;'verticalForm',


'action'=&gt;Yii::app()-&gt;createUrl(&#036;this-&gt;route),


    'method'=&gt;'get',


	'htmlOptions'=&gt;array('class'=&gt;'form-inline well'),

)); ?>

<?php echo $form->dropDownListRow($model, ‘a’, CHtml::listData($a, ‘id’, ‘a1’), array(‘prompt’ => ‘’,‘class’=>‘span3’)); ?>

<?php echo $form->dropDownListRow($model, ‘b’, CHtml::listData($locationList, ‘id’, ‘a2’), array(‘prompt’ => ‘’,)); ?>

<?php $this->widget(‘bootstrap.widgets.TbButton’, array(‘buttonType’=>‘submit’, ‘label’=>‘Search’,‘htmlOptions’=>array(‘class’=>‘btn btn-primary’))); ?>

<p></p>

<?php if(isset($_GET[‘ScheduleForm’]))

{

echo &quot;Filter by area &quot;;


echo &#036;form-&gt;CheckBoxList(&#036;model, 'c', CHtml::listData(&#036;c, 'id', 'c1'), array('uncheckValue'=&gt;'N'));


&#036;this-&gt;endWidget(); 

}

you have to specify the model name and the field name something as following


$_GET["NameOfYourModel"]["nameOfYourField"];

paste the following code in your view at the top to get a dump of GET values


echo "<pre>";

print_r($_GET);

Ok but will it solve the url problem which I discussed earlier?

Which url problem I dont remember

The Url discloses the table name and fields associated with it.So,how to avoid that case?

There is no way to "hide" it.

You may change the models Classname and override the tableName() method. The URL will show the models name instead of the tablename.

Field names cannot be hidden by default (unless you override CActiveRecord and implement some kind of mapping functionality).

To use POST instead of GET just set the ‘method’-parameter to ‘post’ in your code above and use $_POST in your controller.