我怎样才能使$validation
错误,我尝试了这个但是它永远不会对我失真。
if (isset($_POST['submit'])) {
// starting date post data
$startDay = $_POST['startDay'];
$startMonth = $_POST['startMonth'];
$startYear = $_POST['startYear'];
// ending date post data
$endDay = $_POST['endDay'];
$endMonth = $_POST['endMonth'];
$endYear = $_POST['endYear'];
// team post data
$team = $_POST['selectTeam'];
$validation = true;
if ($validation) {
if (!isset($startDay) || $startDay === 'defaultDay') {
$validation = false;
}
if (!isset($startMonth) || $startMonth === 'defaultMonth') {
$validation = false;
}
if (!isset($startYear) || $startYear === 'defaultYear') {
$validation = false;
}
if (!isset($endDay) || $endDay === 'defaultDay') {
$validation = false;
}
if (!isset($endMonth) || $endMonth === 'defaultMonth') {
$validation = false;
}
if (!isset($endYear) || $endYear === 'defaultYear') {
$validation = false;
}
if (!isset($team) || $team === 'defaultTeam') {
$validation = false;
}
if ($validation=true) {
echo 'testing';
} elseif ($validation=false) {
echo 'false';
}
}
}
答案 0 :(得分:0)
问题是
if ($validation = true) {
echo 'testing';
} else if ($validation = false) {
echo 'false';
}
将其更改为
if ($validation === true) {
echo 'testing';
} else{
echo 'false';
}