redirect() not working - any idea or hint?? |
[eluser]Jan_1[/eluser]
Hi everybody! Could someone please help me or give me a hint how to solve it? I am doing a survey. That happens on my_domain.com/question/index.php I have a JQuery/Javascript, that posts data to a CI controller (my_domain.com/vote/index.php). The Javascript is called from the question-view (by question-controller) In my session are userdata "question_number" and "last_question". In my vote-controller, called by the javascript, I do want to do a redirect to the 'survey-result-page' if $question_number > $last_question. vote.php: Code: if( $question_number > $last_question) Or is it not that but a .htaccess-question? Code: <IfModule mod_rewrite.c> Every hint appriciated! Thank You!
[eluser]Tpojka[/eluser]
CodeIgniter helper function redirect() uses PHP header() native function. Nothing mustn't be sent to browser before redirect() nor echo like you have been echoing "x". You can check it in system/helpers/url_helper.php ln 540 and ln 542. Question is why do you need echo if you want to make redirect to another page.
[eluser]Jan_1[/eluser]
So, what I did now is Code: if( $question_number > $last_question) That's not really good, but a solution for now. I will rework the 'survey-result-page' later, so, that I do not have to redirect but include the 'result-view'. That will be nicer.
[eluser]Tpojka[/eluser]
If you move echo 'x' from code snippet in first post, redirect() will make the job pretty much.
[eluser]Jan_1[/eluser]
o_O Tpojka, are you kidding? Thanks for trying to help.
[eluser]CroNiX[/eluser]
Also, redirect() is for redirecting to your domain, not external domains like google. redirect() expects segments, to which it appends automatically to the base_url(). Code: if( $question_number > $last_question) |
Welcome Guest, Not a member yet? Register Sign In |