如何检查多个isset($ _ POST ['something'])?

How to check multiple isset($_POST['something'])? with below mentioned code function is call without set anything? what mistake am I doing

My code is here

if(!isset($_POST['username']) || $_POST['email'] || $_POST['password'] || $_POST['confirm_pass'] || $_POST['gender'] || $_POST['country']== "") 

{   $username = $this->input->post('username');
    $email = $this->input->post('email');    
    $password = $this->input->post('password');
    $confirm_password = $this->input->post('confirm_pass');
    $gender = $this->input->post('gender');
    $country = $this->input->post('country');
    $this->signupdata->submit_data($username,$email,$password,$confirm_password,$gender,$country);     
 exit(); }
 $this->load->view('signup_view'); 

A better way to check for empty / not set fields may be like this. Play around this to achieve desired results:

<?php   
    $req = array("username", "email", "password", "confirm_pass", "gender", "country");
    foreach($req AS $r) {
        if(empty($_POST[$r])) {
            $error = $r . " is a required field";
        } else {
            $username = $this->input->post('username');
            $email = $this->input->post('email');    
            $password = $this->input->post('password');
            $confirm_password = $this->input->post('confirm_pass');
            $gender = $this->input->post('gender');
            $country = $this->input->post('country');
            $this->signupdata->submit_data($username,$email,$password,$confirm_password,$gender,$country);     
            exit();
            $this->load->view('signup_view');
        }    
    }
?>

isset accept multiple variable

In your case, you can do

if (!isset($_POST['username'], $_POST['email'], $_POST['password'], $_POST['confirm_pass'], $_POST['gender'], $_POST['country']) ) {

}

I should also mention that isset will only return true if all variable is set

http://php.net/manual/en/function.isset.php

From Doc:

If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. Evaluation goes from left to right and stops as soon as an unset variable is encountered.

empty returns an error or a notice, if the string is not set.

I personaly use the !isset funtions.