我有一個PHP窗體檢查發佈文本和圖像的問題。我如何處理表單檢查這兩種類型的數據?PHP窗體檢查文本和圖像
$latErr = $lngErr = $photoErr = "";
$lat = $lng = $photo = "";
//what if i am not using form action-PHP_SELF, currently i am use anotherfile.php, what do i use below?
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["inputfield1"])) {
$latErr = "Latitude is required. Enable your browser geolocation.";
} else {
$lat = test_input($_POST["inputfield1"]);
}
if (empty($_POST["inputfield2"])) {
$lngErr = "Longitude is required. Enable your browser geolocation.";
} else {
$lng = test_input($_POST["inputfield2"]);
}
//can i check for image like this?
if (empty($_POST["photo"])) {
$photoErr = "Please select your image.";
} else {
$photoErr = test_input($_POST["photo"]);
}
}
如果我不使用form action =「<?php echo htmlspecialchars($ _ SERVER [」PHP_SELF「]);?>」我使用form action =「addfile.php」 – user2192094