David David - 1 year ago 87
PHP Question

Codeigniter reset the function in URL

Not even sure the best way to describe this as a question so please feel free to change it.

I have

Function mainfunction()
in my controller that controls and loads a particular view via

I have another function,
Function updater()
in the same controller whose only job is to run a one-line update query; it is called from a button on mypage. After the update query runs, I call
from within
, so that after the user clicks the button, mypage is immediately reloaded and the user sees the result of his call to

This appears to work on the surface: the
function runs the update and when it's finished I see mypage again, having been loaded from
. The problem is that the URL is still pointing to /updater, with the effect that if the user hits a page refresh, it runs the update function again. How can I make it so that once the updater() function runs, it truly redirects the user back to /mainfunction in the URL?

Answer Source

Do like this:

function mainFunction(){

function updater(){
 //some code...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download