[英]Slim Framework $_GET 404 error
您好,所以我這里有一個簡單的代碼,它將在列中進行更新,並根據GET參數重定向到頁面。 我的代碼在這里:
在我的html中:
<a href="/user/admin/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>
並在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);
}
}
當我嘗試單擊“ Move
出現404錯誤。 我是否正確獲得參數sponsor
? 還是這里有問題?
似乎您在HTML中的鏈接不正確。 您的路線指出該路徑應為:
<a href="/user/admin/table/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>
不
<a href="/user/admin/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>
您缺少/ user / admin / 表部分,這就是為什么您會收到404的原因。它無法解析為正確的路由。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.