I get the Mangode ID query string. How to verify this ID? I want that if there is no valid redirect redirect ID on any other URL, then
get the query string:
if (count ($ _GET)> 0 & Amp; amp; $ _GET [uid ']) {// string query gets the id $ query = array ("_ id" => New Mongoode ($ _GET [' uid '])); $ User = DB :: findone ('users', $ query); } Else {// If unavailable, the query string header does not exist ('location:' .ADMIN_URL. '/ Items / forbidden.php'); }
plz help ... thanks
in new PHP The Mongo Library is the best way to check the validity of a string: (thanks for the Yii2 code)
function isValid ($ value) {if ($ value instanceof \ MongoDB \ BSON \ ObjectID) {Return true; } Try {New \ MongoDB \ BSON \ Object ($ value); Back true; } Hold (\ Exceptions $ E) {return false; }}
Comments
Post a Comment