开发者

PHP/codeigniter: Link not working when clicked, but fine if opened in new tab

On one particular page I have a button that toggles a certain field in the db. The function is

 function source_toggle_paid($event_id = null, $attendee_id = null)
{
    $this->authentication->checkLogin(); // Check if the user is logged in

    // Check the parameters provided are null
    if ($attendee_id == null || $event_id == null)
    {

        // If either attendee or event ids given are null, give an error message
        $data = array(
                        'type' => 'error',
                        'message' => $this->message_list->get('DOES_NOT_EXIST', 'attendee') . ' ' . $this->message_list->get('BACK_TO_SOURCE_HOME')
        );

        // Output the error message

        $this->load->view('template/main_header');
        $this->load->view('template/message', $data);
        $this->load->view('template/main_footer');  

    }
    else    // Otherwise, parameters are not null
    {


        //Load the attendee model, and toggle the paid status of the attendee
        $this->load->model('Attendee');
        $this->Attendee开发者_开发百科->toggle_field('paid',$attendee_id);
        //Redirect the user back to the attendees page, with the used search term
        redirect('admin/source_attendees/'.$event_id);
                    //redirect('admin/source_attendees/'.$event_id);


    }
}

When I click the button I get redirected to the 404 page and the dp is unchanged, upon further playing I've found the function is never being reached. However if I type in the url manually it works, and if I right click and open in new tab, it works too


how does the routes file look like ? i got a problem that looked similar and took care of it with the routes.php settings , you should add smth like

$route['....source_toggle_paid/(:any)'] = "....source_toggle_paid";

make shure you change .... with you're controller name and then fetch the variables with

$event_id = $this->uri->segment(3); $attendee_id = $this->uri->segment(4);

make shure you change you're uri segment with the correct ones

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜