Welcome Guest, Not a member yet? Register   Sign In
[Solved] Redirect Issue Codeigniter
#1

(This post was last modified: 12-17-2016, 03:12 AM by wolfgang1983.)

I am unable to redirect back to url I have set

When I am in http://localhost/myproject/newthread/1

And I echo out $forum_id id displays 1 which is correct.


PHP Code:
<?php

class Newthread extends MX_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        // Other data 
        // This will be in success part of form validation just redirect atm
        $forum_id $this->uri->segment(2);
        redirect('forum') . $forum_id;
    }



I want to be able back to redirect('forum') . $forum_id;

http://localhost/myproject/forum/1

But for some reason when I redirect it does not add the variable I have set instead redirects to

http://localhost/myproject/forum/

How to make sure when redirect it can redirect with added uri segment


Code:
$route['forum/(:num)'] = 'catalog/qna/forum/index/$1';
$route['newthread/(:num)'] = 'catalog/qna/newthread/index/$1';
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

PHP Code:
redirect("forum/$forum_id"); 
Reply
#3

(This post was last modified: 12-17-2016, 03:13 AM by wolfgang1983.)

(12-17-2016, 03:05 AM)pdthinh Wrote:
PHP Code:
redirect("forum/$forum_id"); 

It worked like


PHP Code:
redirect('forum/' $forum_id); 


For some reason works on site_url('forum/') . $forum_id but not redirect('forum/') . $forum_id;
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

(12-17-2016, 03:12 AM)wolfgang1983 Wrote:
(12-17-2016, 03:05 AM)pdthinh Wrote:
PHP Code:
redirect("forum/$forum_id"); 

It worked like


PHP Code:
redirect('forum/' $forum_id); 


For some reason works on site_url('forum/') . $forum_id but not redirect('forum/') . $forum_id;

site_url() return string so concatenation works, but redirect will stop the current script.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB