![]() |
redirect issue in my function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: redirect issue in my function (/showthread.php?tid=64838) |
redirect issue in my function - doomie22 - 03-31-2016 Hi all, I am trying to get the else part of this function to work. PHP Code: public function login_user_process(){ At the moment if I login correctly it works and lets me in, but if I get it wrong I just get a blank screen and it stays in the function instead of redirecting back to admin/login. Can anyone help please? Thanks, Doomie RE: redirect issue in my function - josepostiga - 03-31-2016 Try to remove the echo "error" part... See https://codeigniter.com/user_guide/helpers/url_helper.html?highlight=redirect#redirect Quote:In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers. RE: redirect issue in my function - doomie22 - 03-31-2016 I have removed it and still it does the same. RE: redirect issue in my function - PaulD - 03-31-2016 Looking at your function, if no rows are returned from your query, the function just ends. You should preface your foreach with a check to see that there is actually some data to deal with. The 'else' part of that if would then deal with the fact that the login code does not exist, ie redirect back to login or error page or return an error message. Hence the blank screen when you use the wrong credentials. |