redirect() not working - any idea or hint?? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: redirect() not working - any idea or hint?? (/showthread.php?tid=60228) |
redirect() not working - any idea or hint?? - El Forum - 02-09-2014 [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! redirect() not working - any idea or hint?? - El Forum - 02-09-2014 [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. redirect() not working - any idea or hint?? - El Forum - 02-10-2014 [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. redirect() not working - any idea or hint?? - El Forum - 02-10-2014 [eluser]Tpojka[/eluser] If you move echo 'x' from code snippet in first post, redirect() will make the job pretty much. redirect() not working - any idea or hint?? - El Forum - 02-10-2014 [eluser]Jan_1[/eluser] o_O Tpojka, are you kidding? Thanks for trying to help. redirect() not working - any idea or hint?? - El Forum - 02-10-2014 [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) |