Welcome Guest, Not a member yet? Register   Sign In
problem in search function_automatically redirect to page[solved]
#1

[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

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>

&lt;form  action="search.php"  method="post"&gt;
search  &lt;input type="text" name="searchbox1" /&gt; <br/>

&lt;input type="submit"  name="searchbutton" value="search" /&gt;

&lt;/form&gt;

&lt;/html&gt;

the sucsess view code(searches.php) ::

Code:
&lt;?php

echo "hi".$data1['userName'] ;


?&gt;

plz help me ?

#2

[eluser]deqer[/eluser]
&lt;form action="search.php"&gt; search.php ? try action=""

or &lt;form action="otp/"&gt; or &lt;form action="http://localhost/t/index.php/search/otp"&gt;

#3

[eluser]asmaa kamal[/eluser]
thanks , it works Smile
#4

[eluser]skhan[/eluser]
i tried this
but error
Undefined variable $data1 in searches.php

someone help me pls.




Theme © iAndrew 2016 - Forum software by © MyBB