mercredi 13 décembre 2017

full if then statement is not being read php

I have a program that evaluates an if then statement and returns true or false

false = everything is good

true = still need more info

so here is my code

function city_state_zip_requirement($parameters_ar){
    //clear requirements if all the address fields are filled and the first and last or company is filled
    if (!empty($parameters_ar['Address']) && !empty($parameters_ar['City']) && !empty($parameters_ar['State']) && !empty($parameters_ar['Zip']) && (!empty($paramenters_ar['First'] && !empty($paramenters_ar['Last'])) || !empty($paramenters_ar['Company']))){
    return false;
    // clear the requirement if the first and last name field are filled and there is no filled field in the address city state or zip column
    } elseif ((!empty($parameters_ar['First']) && !empty($parameters_ar['Last']) && empty($paramenters_ar['Address']) && empty($paramenters_ar['City']) && empty($paramenters_ar['State']) && empty($paramenters_ar['Zip'])) || (!empty($parameters_ar['Company']) && empty($paramenters_ar['Address']) && empty($paramenters_ar['City']) && empty($paramenters_ar['State']) && empty($paramenters_ar['Zip']))){
    return false;
    // clear the requirement if the email address field is filled and the adress fields are either all filled or all empty
    } elseif (!empty($parameters_ar['Email_Address']) && empty($parameters_ar['Address']) && empty($parameters_ar['City']) && empty($parameters_ar['State']) && empty($parameters_ar['Zip'])){
    return false;
    } else {
    return true;
    }}

what I am trying to accomplish is if the user enters info into a first (first name) and last (last name) or company field the address fields must be either all filled or all empty (i.e. cannot have only state filled for example)

However, upon entering only info for the first and last or company fields the statement is being evaluated to false and it does not make sense to me how this could be happening

Aucun commentaire:

Enregistrer un commentaire