0

I have a page at admin/show_queries with a form in codeigniter like so

<form action="" method = "post">
    <input....
    <input....
    <input type = "submit" name = "view_query" />
</form>

Then in my controller Admin.php, I try to catch the event when someone presses view_query

public function show_queries(){

...
...

  if($this->input=>post('view_query'){
     $this->view_query_function();
  }

  $this->load->view('elex/show_queries');
}

In the same file Admin.php my view_query_function:

public function view_query_function(){
   //DO Something
   ...
   ...
   $this->load->view('elex/view_queries');
}

All of this is working and I'm able to go to the View_queries page without trouble. Here's the problem, that I'm facing<

When I click the button view_queries and the view_queries page loads, it loads on top of show_queries page. Means, when the view_queries page is loaded, I can scroll down and I see the show_queries page, which should not be there. I check the url, and the url hasn't changed either.

What am I doing wrong here?

SowingFiber
  • 1,194
  • 1
  • 12
  • 32

1 Answers1

1

Add a return after calling the function:

 if($this->input->post('view_query'){
     $this->view_query_function();
     return;
  }
Farzad Rastgar Sani
  • 371
  • 1
  • 4
  • 12