Welcome Guest, Not a member yet? Register   Sign In
Problem set_flashdata loads home page?
#1

[eluser]zimco[/eluser]
I've been playing with the CI app Linkster: tearing it apart and putting it back together again to see how it works and there's something i'm not understanding (or broke) with the Delete function.

When i'm logged-in as admin everytime i try to delete an entry in the listings instead of getting the confirm box to do the delete; it actually loads my home page into the pop-up box and never deletes anything because i can't confirm. All the other functions in the listing section: add, edit, show, all work as expected and the confirm works correctly for a logout. Any suggestions on where to look for the problem?

Here's the code for the delete function

Code:
function remove($id)
    {
        confirm('Do you really want to delete this entry?');
        
        $entry = $this->Listings_model->get_entry($id);
        
        // Can only remove your own entries
        if($entry->FK_user_id !== $this->user->id)
        {
            show_error('The entry you are trying to delete does not exist, or it does not belong to you.');
            exit;
        }
                
        $this->Listings_model->delete_entry($id);
        $this->session->set_flashdata('msg', 'Entry Deleted');
        redirect('member/listings');
    }

Here's the code from the confirm_helper
Code:
function confirm($message = 'Are you sure?')
{
    $CI    =& get_instance();
    $segments = $CI->uri->segment_array();

    if( end($segments) != 'yes')
    {
        if ( ! $referrer = $CI->input->server('HTTP_REFERER'))
        {
            // No user agent referrer, use the controller index
            $RTR =& load_class('Router');
            $referrer = $RTR->fetch_directory().$RTR->fetch_class();
        }

        $data['no_href']    = $referrer;
        $data['yes_href']    = implode('/', $segments).'/yes';
        $data['message']    = $message;
        
        echo $CI->template->load('template', 'content/confirmation', $data, TRUE);

        exit;
    }
}

Here's the code for content/confirmation
Code:
<div id="content"> &lt;!-- Begin CONTENT --&gt;
    <div class="boxview">
    
    <h3>&lt;?php echo $message?&gt;</h3>
    
    <p>&lt;?php echo anchor($yes_href, 'Yes'); ?&gt; / &lt;?php echo anchor($no_href, 'No', array('id' => 'confirm_cancel')); ?&gt;</p>
    
    </div>
</div>&lt;!-- End CONTENT --&gt;




Theme © iAndrew 2016 - Forum software by © MyBB