[英]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. 您好,所以我这里有一个简单的代码,它将在列中进行更新,并根据GET参数重定向到页面。 My code is here:
我的代码在这里:
In my html: 在我的html中:
<a href="/user/admin/{{r.tableID}}/move?sponsor={{sponsorID}}">Move</a>
and in the index.php 并在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. 当我尝试单击“
Move
出现404错误。 Do I get the parameter sponsor
correctly? 我是否正确获得参数
sponsor
? Or is there something wrong here? 还是这里有问题?
It appears as if your link in the HTML is incorrect. 似乎您在HTML中的链接不正确。 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. 您缺少/ user / admin / 表部分,这就是为什么您会收到404的原因。它无法解析为正确的路由。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.