02-06-2012, 04:48 AM
[eluser]asmaa kamal[/eluser]
hi
i try to code a function that take userid from inputbox , search it on database and return with all userdata , view it in a page
and the url become :: http://localhost/t/index.php/search/search.php
what is the problem ?
the controller code ::
the model code ::
the original view code is (searchht.php)::
the sucsess view code(searches.php) ::
plz help me ?
hi
i try to code a function that take userid from inputbox , search it on database and return with all userdata , view it in a page
Quote:the problem is that when pressing the search button it give me this error
404 Page Not Found
The page you requested was not found.
and the url become :: http://localhost/t/index.php/search/search.php
what is the problem ?
the controller code ::
Code:
<?php
class Search extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->view('searchht');
$this->load->model('searchdb_model');
}
function otp ()
{
if ($this->input->post('searchbox1'))
{
echo "pressed" ;
$userId=$this->input->post('searchbox1');
$data1['query']=$this->searchdb_model->search_user($userId);
$this->load->view('searchres',$data1);
}
}
}
?>
the model code ::
Code:
<?php
class Searchdb_model extends CI_Model {
var $title = '';
var $content = '';
var $data2 = '';
function __construct()
{
// Call the Model constructor
parent::__construct();
}
public function index()
{
$this->load->database();
}
function search_user($userId){
$this->db->where('userId',$userId);
$query=$this->db->get('users');
if(!$query)
{return false;}
else
{return $query->result() ;}
}}
?>
the original view code is (searchht.php)::
Code:
<html>
<h1> Hello Guys:) </h1>
<form action="search.php" method="post">
search <input type="text" name="searchbox1" /> <br/>
<input type="submit" name="searchbutton" value="search" />
</form>
</html>
the sucsess view code(searches.php) ::
Code:
<?php
echo "hi".$data1['userName'] ;
?>
plz help me ?