Welcome Guest, Not a member yet? Register   Sign In
how to put dynamic info in an array?
#21

[eluser]JHackamack[/eluser]
This seems like a really strange behavior for a redirect not to work. Are you sure that you aren't outputting anything. Also are your links working on the site (aka can you navigate around and only the header redirects aren't working)
#22

[eluser]dadamssg[/eluser]
yeah everything seems to be working except THIS redirect...other ones are working fine. and yeah im sure my 'page' session variable is holding value because im echoing it out into a view
#23

[eluser]JHackamack[/eluser]
so if you say:

echo $page; die();

what result does it give you

Also before you mentioned trying the header option, but it wasn't working, what exactly did you try?
#24

[eluser]JHackamack[/eluser]
Are you echoing anything before the redirect? or print_r()ing anything?
#25

[eluser]dadamssg[/eluser]
not echoing anything before....i have a login in my header on every page. so the idea is to hold what page im on in a session variable so i can use that in my login controller/script. It works in one controller but not in another

i tried this

header("location: http://mysite.com/$page");

heres the relevant login code in its own separate controller
Code:
$this->validation->set_rules($rules);
        
        
                if ($this->validation->run() == FALSE)
                {
                    $page = $this->session->userdata('page');
                    redirect($page);
                }
                else
                {
                    $newdata = array(
                   'logname'  => $this->input->post('username'), );
              
                    $this->session->set_userdata($newdata);
                    $page = $this->session->userdata('page');
                    redirect($page);
                }

heres whats in another controller that works
Code:
function index($page = null)
    {
        //load models
        
        
    $newdata = array(
                   'page'  => 'mains',
               );
        $this->session->set_userdata($newdata);
and heres the third controller that does NOT work
Code:
$row = $data['query']->row();
        $eventid = $row->eventid;
        $page = "event/index/".$eventid;
        $newdata = array(
                   'page'  => $page,
               );
        $this->session->set_userdata($newdata);
but when im echoing that session['page'] variable out and it looks correct
#26

[eluser]JHackamack[/eluser]
When you say it does not work are you implying that it never redirects correctly? Never seems to set the variable, or never gets to your "Query" (are you sure the query is triggered successfully?)

Have you enabled error reporting
error_reporting(E_ALL);
ini_set('display_errors',1);

Also, im not sure if its caps sensative, but could you try
header(“Location: http://mysite.com/".$page);

Im just running through a list of options I would try and make sure everything is correct.
#27

[eluser]Dyllon[/eluser]
I may have missed it but what exactly is the type of error you are receiving from this?
Is your event controller throwing an error or are you receiving a 404 or are you being redirected to your login page?

What happens when you try to access the events page (mysite.com/event/index/867) when logged in?

You've got bits and pieces of your code spread over numerous posts, I recommend posting your entire controllers that are involved.

Code that you may think is irrelevant may not be.
#28

[eluser]WebsiteDuck[/eluser]
Like Dyllon said, try accessing the page directly from your browser.

If redirect and header don't work, but they work for other controllers, its probably a problem with your event/index, can you post that code?
#29

[eluser]dadamssg[/eluser]
heres my event/index. i am being redirect back to my mains/index controller everytime
Code:
<?php

class Event extends Controller {

    function Event()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('date');
        $this->load->helper('text');
        $this->load->helper('form');
        $this->load->library('session');
        $this->load->model('Eventmodel');
        $this->load->model('Loginmodel');
    }

    function index($id = null)
    {
        
        
        if (isset($id) && is_numeric($id))
        {
              $yes = $this->Eventmodel->get_exists($id);
              if($yes !== 1){redirect('mains');}
            }
            else
            {
              redirect('mains');
            }
        $data['query'] = $this->Eventmodel->get_event($id);
        $row = $data['query']->row();
        $data['title'] = clean_up($row->title);
        $eventid = $row->eventid;
        $page = "event/index/".$eventid;
        $new = array(
                   'page'  => $page,
               );
        $this->session->set_userdata($new);
        
        $data['notifications'] = $this->Loginmodel->get_notifications();
        $data['messages'] = $this->Loginmodel->get_messages();
        $this->load->view('header_view', $data);
        #####decide which views to load###################
        if($this->session->userdata('logname') == "")
        {
        $this->load->view('login_view', $data);
        }
        else
        {
        $this->load->view('logged_view', $data);
        }
        
        
        $this->load->view('event_view', $data);
        $this->load->view('footer_view');
    }
#30

[eluser]Flemming[/eluser]
surely your problem is in this IF ...

Code:
$yes = $this->Eventmodel->get_exists($id);
if($yes !== 1){redirect('mains');}

presumably $yes is not equal to 1 so you always get redirected to /mains ?




Theme © iAndrew 2016 - Forum software by © MyBB