Welcome Guest, Not a member yet? Register   Sign In
redirect ?
#1

[eluser]Isern Palaus[/eluser]
If your controller is Users and your action is dispo, and I assume that you want to show the username, you've to redirect("users/dispo/$username");
#2

[eluser]fuji2009[/eluser]
Hello i have a problem

I use redirect but how do for redirect to the same page, when i clik on redirect i am redirect on index, and i would be redirect to the same page as href="#"

So how do ? thank you


Code:
function dispo($username){
        $user_login_id = $this->session->userdata('id');
        $this->profile_model->set_on($user_login_id);
        redirect('#');
    }


I test it but no work
#3

[eluser]fuji2009[/eluser]
no my redirect is on all page, so when i am on controller, profil or photos or ect, i have the function dispo , so i can t put a controller fixed in redirect

thank you
#4

[eluser]Unknown[/eluser]
Why don't you use the URI-Class? In this case most likely $this->uri->uri_string() ?

e.g. redirect($this->uri->uri_string());
#5

[eluser]eBuildy[/eluser]
hash (#) is Javascript, you cannot redirect from Php just # ! Else you can use some AJAX code to call your Php controller
#6

[eluser]fuji2009[/eluser]
how can i do ?

Thanks you
#7

[eluser]eBuildy[/eluser]
If you use JQuery for instance:

$.post('/user/dispo' + username,function(response)
{
alert('OK');
});

Will call through AJAX your function!
#8

[eluser]ludovic[/eluser]
Depends where you are. For example if data come from form you can write a hidden field
Code:
<?php echo form_hidden('redirect_url', uri_string()); ?>

And after retrieve it in your Controller or Model like this:

Code:
redirect($this->input->post('redirect_url'), 'location');


Or you can simply use
Code:
redirect($_SERVER['HTTP_REFERER']);




Theme © iAndrew 2016 - Forum software by © MyBB