'Correct usage of 'if !empty' for multiple post values

Before completing registration I wan't to check if all submitted post values aren't empty. The POST values will be assigned to the variables only when all input fields have been filled. Else missingFields will be displayed in the URL.

So what I came up with seems to work, however I wonder if the !empty is actually going through all post values, just like individually checking all post values with !empty. If not, what should be changed?

if (!empty($_POST['first']) && ($_POST['last']) && ($_POST['email']) && ($_POST['password'])) {
    // If the posts contain any values, assign them to these variables.
    $first_name = $_POST['first'];
    $last_name = $_POST['last'];
    $mail_address = $_POST['email'];
    $password = $_POST['password'];
    $hash = hash('sha256', $password); // Password will be hashed.

    // Check if the email already exists or not.
    $existingUser = 'SELECT * FROM account WHERE sMailaddress = :mail';
    $stmt = $pdo->prepare($existingUser);
    $stmt->execute([
        ':mail' => $mail_address
    ]);

    // When no results are found, insert values into database.
    if ($stmt->rowCount() == 0) {
        $registerUser = 'INSERT INTO account (sFirstname, sLastname, sMailaddress, sPassword)
        VALUES (:first_name, :last_name, :mail_address, :pass)';

        $stmt = $pdo->prepare($registerUser);
        $stmt->execute([
            ':first_name' => $first_name,
            ':last_name' => $last_name,
            ':mail_address' => $mail_address,
            ':pass' => $hash
        ]);

        header('Location: template/authentication.php?registrationCompleted');
    } else {
        header('Location: template/authentication.php?alreadyExists');
    }
} else {
    header('Location: template/authentication.php?missingFields');
}
php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source