Textbox Value To Url

Hi everyone…

i have this form




<form name=form1 method="post">

    Quarter: &nbsp;

	<select style="width:150px">

	<option value="0"></option>}

	<option value="1">1</option>

	<option value="2">2</option>

	<option value="3">3</option>

	<option value="4">4</option>

	</select> 	

	<br><br>

	

	Year: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

	<input type="text" name="year" style="width:145px"/><br><br>	

	

	Site: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

	<select>

	  <option value="Select"></option>}

	  <option value="1">ALL SITES</option>

	  <option value="1">BAGUIO</option>

	  <option value="2">LA UNION</option>

	  <option value="3">ALBAY</option>

	  <option value="4">NCR</option>

	  <option value="5">DAVAO</option>

	  <option value="6">ZAMBOANGA</option>

	  <option value="7">RIZAL</option>

	  <option value="8">SOUTH COTABATO</option>

	  <option value="9">SAMAR</option>

	</select> <br><br>

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;



and this as the link or output




	<?php 

	$year = @$_GET['year'];

	$year = @$_POST['year'];

	

	echo CHtml::link('GENERATE REPORT', array('index','type'=>ireport, 'file' => 'ASQBorderline','site'=>'BAGUIO','Year'=>$year,'Quarter'=>'2')) 

	?>



now my problem is how will i get the value of the quarter[dropdown], the year[which is a textfield] and the site[which is also a dropdown] to the url … i am currently trying to get the year first that’s why my code is like that … this is for a report generation.

thanks in advance for all your help. :)

You haven’t given either select element a name, so you won’t be able to identify them in PHP. You need something like:




<select name="quarter">

    ...

</select>



Which you can retrieve with:




$quarter = Yii::app()->request->getParam('quarter');



That’s assuming that you need to be able to get the value from both GET and POST.

Also, you should really be generating your forms using CHtml’s methods, especially when opening the form. If you ever want to add CSRF protection, you’re going to have to go back and edit every form you’ve created.

this works fine but what about in dropdown … i couldn’t get the values chosen. thank you in advance

What I said above will get the value of the dropdown. You need to give more detail about what’s not working for you or what you’re expecting to happen.