你好親愛的網絡朋友,今天我有一個問題,我不知道如何驗證 POST 中的 INPUT 數據,如果有人可以幫助我驗證這些數據,我將不勝感激,這就是代碼:include("GameEngine/Village.php");$unarray = array(1 => U1, U2, U3, U4, U5, U6, U11, U12, U13, U14, U15, U16, U21, U22, U23, U24, U25, U26, U31, U32, U33, U34, U35, U36, U41, U42, U43, U44, U45, U46, U0);if (isset($_GET['id']) && $_GET['id'] == 1) { $res_qty = $_POST['resqty']; $cost = $res_qty * 30; $allres_qty = $res_qty * 100000; $database->query("UPDATE " . TB_PREFIX . "users SET `gold` = `gold`- " . $cost . " WHERE id =" . $session->uid); $database->query("UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` + " . $allres_qty . ", `clay` = `clay` + " . $allres_qty . ", `iron` = `iron` + " . $allres_qty . ", `crop` = `crop` + " . $allres_qty . " WHERE wref =" . $village->wid); $_SESSION['info'] = $allres_qty . " Wood, Clay, Iron, Crop, added at the cost of " . $cost . " gold."; header("Location:dorf1.php");}if (isset($_GET['id']) && $_GET['id'] == 2) { $troop_type = $_POST['trooptype']; $troop_qty = $_POST['troopqty']; $cost = $troop_qty * 30; $dt = array(); header("Location:dorf1.php"); for ($x = 1; $x < 11; $x++) { $dt[$x] = 3333; if ($x == $troop_type) $dt[$x] = floor($troop_qty * 3333); } $tribe = $database->getUserField($database->getVillageField($village->wid, "owner"), "tribe", 0); if ($tribe == 1) { $u = ""; } elseif ($tribe == 2) { $u = "1"; } elseif ($tribe == 3) { $u = "2"; } elseif ($tribe == 4) { $u = "3"; } else { $u = "4"; } $database->modifyUnit( $village->wid, array($u . "1", $u . "2", $u . "3", $u . "4", $u . "5", $u . "6", $tribe . "0", "hero"), array($dt[1], $dt[2], $dt[3], $dt[4], $dt[5], $dt[6], 0), array(1, 1, 1, 1, 1, 1) );}您好,我需要驗證的是我給我的用戶提供的部隊和資源的數量,這是在我的游戲中提供部隊的腳本,但我需要驗證部隊和資源,非常感謝!如果有人能幫助我,我將不勝感激!
驗證來自 POST 值的輸入?
慕碼人2483693
2023-04-21 10:13:28