wobsoriano
wobsoriano

Reputation: 13462

Slim Framework $_GET 404 error

Hello so I have a simple code here which will do an update in a column and redirect to a page based on the GET parameter. My code is here:

In my html:

<a href="/user/admin/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>

and in the index.php

$app->get('/user/admin/table/:table_id/move', 'RecycleTable');

function RecycleTable($table_id)
{
    $session = new \RKA\Session();
    $app = \Slim\Slim::getInstance();
    if (!$session->type) {
        $app->redirect('/user/login');
    }
    else {
        $sponsorID = $app->request()->get('sponsor');   
        $db = new db();
        $bind = array(
            ':table_id' => $table_id
        );
        $update = array(
            'status' => '2'
        );
        $db->update("tables", $update, "tableID = :table_id", $bind);
        $db = null;
        $app->redirect('/user/admin/table/'.$sponsorID);
    }
}

When I try to click Move I get a 404 error. Do I get the parameter sponsor correctly? Or is there something wrong here?

Upvotes: 0

Views: 167

Answers (1)

RhapX
RhapX

Reputation: 1683

It appears as if your link in the HTML is incorrect. Your route states that the path should be:

<a href="/user/admin/table/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>

not

<a href="/user/admin/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>

You are missing the /user/admin/table part which is why you would be receiving a 404. It cannot resolve to the correct route.

Upvotes: 2

Related Questions