This question is similar to this one but a little different. I am trying to create a search feature in my code. However when i use the $_GET variable i am not able to echo-out the search value entered.
Here is the code separated in 3 files(i am using a custom MVC design and not any particular framework)
Search form
<form action = "maina2/getStaffname" method = "get">
<select name = "choice">
<option value = "staffname" name = "staffname">title</option>
<option value = "id" name = "id"> author</option>
</select>
<input name= "search" type ="text" size="65" maxlength = "88" style = "display:inline">
<input name = "mysearch" type="submit" style = "display:inline">
</form>
The search controller
<?php
class Search extends Controller {
public function __construct(){
parent::__construct();
}
function Index() {
$this->view->getStaffname = $this->model->getStaffname();
$this->view->render('search/index');
}
function getStaffname() {
$this->model->getStaffname();
}
}
And this is the search model file
<?php
class Search_Model extends Model{
public function __construct() {
parent::__construct();
echo 'This is the SEARCH MODEL CLASS <br />';
}
public function getStaffname(){
if(isset($_GET['search'])) {
echo $_GET['search'];
}
}
}
What surprices me is that when i change the method to POST then i am able to echo out the search value. What might be wrong with my technique?