[eluser]tommebasso[/eluser]
Hi
I'm through several hours of headbanging upon my problem and a lot of forum searching, but didn't find a solution.
prior to deleting an article I'm presenting the user a page asking him if he really wants to delete it. if he denies i'm doing a redirect to the show-view of the article, which goes like this:
Code: function del($id = '')
{
if($this->input->post('mysubmit') == 'ja'):
$this->Aktuell_model->del_artikel($this->input->post('id2'));
redirect($this->data['controller'],'refresh');
elseif($this->input->post('mysubmit') == 'nein'):
redirect($this->data['controller'].'/show/'.$this->input->post('id2'),'refresh');
endif;
$this->data['record'] = $this->Aktuell_model->get_artikel($id);
$this->data['view']['content'][] = $this->load->view('delete', $this->data, TRUE);
$this->load->view('page',$this->data);
}
my site works just well with firefox, opera, safari (both mac and pc), but when it comes to win ie (6+7), instead of redirecting i get the pre-delete-page over and over again.
what the hack is going on here?
oh, and by the way: i looked in the logs and while ff, safari and opera produce some messages (unset variables etc...), ie doesn't produce anything. could it be this is related to the redirect-problem? or anything? I'm just desperate here
(sorry, i just noticed that i should have posted this under code und app dev)
[eluser]Michael Wales[/eluser]
Remember - redirect is nothing more than a function call. It will call that function, then return to where it left off in the current function.
Best practice is to follow all redirect() calls with an empty return.
Code: function del($id = '')
{
if($this->input->post('mysubmit') == 'ja'):
$this->Aktuell_model->del_artikel($this->input->post('id2'));
redirect($this->data['controller'],'refresh');
return;
elseif($this->input->post('mysubmit') == 'nein'):
redirect($this->data['controller'].'/show/'.$this->input->post('id2'),'refresh');
return;
endif;
$this->data['record'] = $this->Aktuell_model->get_artikel($id);
$this->data['view']['content'][] = $this->load->view('delete', $this->data, TRUE);
$this->load->view('page',$this->data);
}
[eluser]tommebasso[/eluser]
hi michael
thank you for your suggestion but i'm afraid to say that even though i inserted the return commands i'm still trapped on the pre-deletion-page when checking it with ie (damn ie!)
[eluser]narkaT[/eluser]
try redirecting by 'location' instead of 'refresh'.
that proved to be more reliable
[eluser]tommebasso[/eluser]
so this ist what my code looks like now
Code: if($this->input->post('mysubmit') == 'ja'):
$this->Aktuell_model->del_artikel($this->input->post('id2'));
redirect($this->data['controller'].'/show/'.$this->input->post('parentid'),'location', 301);
return;
elseif($this->input->post('mysubmit') == 'nein'):
redirect($this->data['controller'].'/show/'.$this->input->post('id2'),'location', 301);
return;
endif;
$this->data['record'] = $this->Aktuell_model->get_artikel($id);
$this->data['view']['content'][] = $this->load->view('delete', $this->data, TRUE);
$this->load->view('page',$this->data);
and this is the form:
Code: <form action="http://www.domain.de/cms/index.php/aktuell/del/5157.html" method="post">
<input type="hidden" name="id2" value="5157" />
<fieldset>
<p><label>Label</label><span class="inputbereich">Content</span></p>
...
</fieldset>
<div class="buttonrow">
<button type="submit" name="mysubmit" value="ja"><img src="./lay/delbig.png" />yes, delete it</button>
<button type="submit" name="mysubmit" value="nein"><img src="./lay/cancel.png" />no, i want to go back</button>
</div>
</form>
but IE still keeps my nailed on the same page, whether i click on "yes, delete it" or on "no, i want to go back" (and i tried it with IE on two different machines)
i just don't have any clue here
[eluser]sl3dg3hamm3r[/eluser]
I usually do instead of a 'return' even an 'exit' in order to make sure there is nothing else executed after... but I doubt this will solve it.
If you just create a dummy-function, containing only a redirect and nothing else, it does neither work in IE?
[eluser]omar-303[/eluser]
if you enabled the output compression in the config.php file please try to disable it and test again ...
[eluser]tommebasso[/eluser]
after some days, in which i couldn't apply myself to the ie-problem, i now made up a test-function as sl3dg3hamm3r suggested, and this works fine with ie. ok then, it's my code that's tricking me out. but where?
i have no caching enabled, no compression and no echos (except ofcourse in the views), so there shouldn't be any data sent to the browser prior the redirection header. how can it be then, that i run into the trap only with ie?
[eluser]NZmuzzer[/eluser]
I use elseif very rarely so am unsure of phrasing, but would presume you need curly brackets for multiple statements? I use curly brackets for all if statements as I think it helps define the layout of the code better and makes it more readable...
I doubt this will solve your particular problem, but all I can suggest is you try changing
Code: if($this->input->post('mysubmit') == 'ja'):
$this->Aktuell_model->del_artikel($this->input->post('id2'));
redirect($this->data['controller'].'/show/'.$this->input->post('parentid'),'location', 301);
return;
elseif($this->input->post('mysubmit') == 'nein'):
redirect($this->data['controller'].'/show/'.$this->input->post('id2'),'location', 301);
return;
endif;
$this->data['record'] = $this->Aktuell_model->get_artikel($id);
$this->data['view']['content'][] = $this->load->view('delete', $this->data, TRUE);
$this->load->view('page',$this->data);
to Code: if($this->input->post('mysubmit') == 'ja'):
{
$this->Aktuell_model->del_artikel($this->input->post('id2'));
redirect($this->data['controller'].'/show/'.$this->input->post('parentid'),'location', 301);
return;
}
elseif($this->input->post('mysubmit') == 'nein'):
{
redirect($this->data['controller'].'/show/'.$this->input->post('id2'),'location', 301);
return;
}
endif;
$this->data['record'] = $this->Aktuell_model->get_artikel($id);
$this->data['view']['content'][] = $this->load->view('delete', $this->data, TRUE);
$this->load->view('page',$this->data);
|