soumya_acube
soumya_acube

Reputation: 43

Condition always returning true

I want to check if email is required and if yes,check email is not null ,Whenever i am checking this condition the variable validation_ok is always returning 1 as the value . Even if the condition satisfies, every time it is returning true.

This is my code:

if ($validations['customer_reg_email'] == 'required' && $email=='') 
            {
                        $validation_ok = false;
                        $status        = 'Please provide a valid email';
                    } 
                  else 
                      {
                        $validation_ok = true;
                    }

I would appreciate your help regarding this issue.Thanks in advance

Upvotes: 0

Views: 43

Answers (1)

stefo91
stefo91

Reputation: 618

It's much better to check your email with empty() and check what you have with var_dump() function.

var_dump($validations['customer_reg_email']);
echo "\n";
var_dump($email);
echo "\n";
$validation_ok = TRUE;
if($validations['customer_reg_email'] == 'required' and empty($email)){
   $validation_ok = FALSE;
   $status = 'Please provide a valid email';
}

Upvotes: 2

Related Questions