if !isset multiple OR conditions

前端 未结 8 1218
一整个雨季
一整个雨季 2021-01-04 06:51

I cannot get this to work for the life of me, it is PHP.



        
相关标签:
8条回答
  • 2021-01-04 07:33

    When you work with POST, use empty(). because when your form send data. It async null for empty input! best way is that:

     if ((!isset($_POST['ign']) || empty($_POST['ign'])) &&
         (!isset($_POST['email']) || empty($_POST['email'])) {
    

    YES! It's Ugly...

    So you can use:

    <?php
     if ( checkInput($_POST['ign']) || checkInput($_POST['email']) ) {
    
      echo "Please enter all of the values!";
        }
    
     else {
    
       echo "Thanks, " . $_POST['ign'] . ", you will recieve an email when the site is         complete!";
    
        }
    
     function checkInput($input){
         return ( !isset($input) || empty($input) );
     }
    ?>
    
    0 讨论(0)
  • 2021-01-04 07:39

    You can try this code:

    <?php
        if(!isset($_POST['ign'], $_POST['email'])) {
            echo "Please enter all of the values!";
        } else {
            echo "Thanks, " . $_POST['ign'] . ", you will receive an email when the site is complete!";
        }
    ?>
    
    0 讨论(0)
提交回复
热议问题