我获得了查询字符串中的MongoDB ID。如何检查此ID的有效性?如果MongoDB ID无效,我想将其重定向到另一个URL。
获取查询字符串:
请帮忙... 谢谢
获取查询字符串:
if(count($_GET)>0 && $_GET['uid']){
//get id from string query
$query = array("_id" => new MongoId($_GET
['uid']));
$user = DB::findone('users',$query);
}else{
//redirect if not exist query string
header('location:'.ADMIN_URL.'/items/forbidden.php');
}
请帮忙... 谢谢