此if语句不起作用。我试图使它成为所有东西必须包含要显示的第一个语句的值,但它只在选择一个值时有效。
<?php
if ((isset($_POST["FirstName"]))&&(isset($_POST['SecondName']))
&&(isset($_POST['email']))&&(isset($_POST["submit"]))) {
echo "You've given all your details";
}
else {
echo "Please enter all your details";
}
?>
答案 0 :(得分:1)
即使输入未填充,也会设置。您需要检查它是否已设置以及是否包含输入。
尝试制作一个功能:
function issetWithInput(&$va){
return (isset($va) && !empty($va));
//checks that it is set and contains input.
}
然后你可以做类似的事情:
if(issetWithInput($_POST["FirstName"])&&issetWithInput($_POST['SecondName'])..) {
答案 1 :(得分:1)
试试这个
<?php
if (isset($_POST['FirstName']) &&
isset($_POST['SecondName']) &&
isset($_POST['email']) &&
isset($_POST['submit']) &&
!empty($_POST['SecondName']) &&
!empty($_POST['FirstName']) &&
!empty($_POST['email'])) {
echo "You've given all your details";
}
else {
echo "Please enter all your details";
}
?>
答案 2 :(得分:0)
这是我在查看表单时所做的事情
<?php
$firstname= $_POST['FirstName'];
$secondname = $_POST['SecondName'];
$email = $_POST['email'];
$submit = $_POST['submit'];
if ($submit)
{
if ($firstname&&$secondname&&$email)
{
echo "You've given all your details";
}
else
echo "Please enter all your details";
}
?>
但是我可能会想念你想要做什么:),如果这根本没有任何意义,请忽略这一点(我仍然是php的新手)