Need Help To Use Else Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaspower
Forum Newbie
Posts: 8
Joined: Fri Jun 13, 2008 6:04 pm
Location: Bend Oregon

Need Help To Use Else Function

Post by gaspower »

Hello,
Need some help with the below code. Currently the below code will send two emails, and that is working fine,

Code: Select all

$name = $firstname . ' ' . $lastname;

      if (ACCOUNT_GENDER == 'true') {
         if ($gender == 'm') {
           $email_text = sprintf(EMAIL_GREET_MR, $lastname);
         } else {
           $email_text = sprintf(EMAIL_GREET_MS, $lastname);
         }
      } else {
        $email_text = sprintf(EMAIL_GREET_NONE, $firstname);
      }

      $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

	$email_text_coupon .= EMAIL_WELCOME . EMAIL_TEXT_COUPON . EMAIL_CONTACT. EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT_COUPON, $email_text_coupon, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
I need to be able to option the second email to be sent when the below code is tru,

Code: Select all

if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) {
I am just not sure how to implement it to correctly option out the second email. I know I need to use the } else { function, but just can not seem to figure it out.

Thanks for any help.

JR
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Need Help To Use Else Function

Post by cpetercarter »

Code: Select all

if (ACCOUNT_GENDER == 'true') 
{
// some code
}
elseif (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) )
{
// some more code
}
gaspower
Forum Newbie
Posts: 8
Joined: Fri Jun 13, 2008 6:04 pm
Location: Bend Oregon

Re: Need Help To Use Else Function

Post by gaspower »

Hello and thank you for the response,

I tried the below, but for some reason it does not send the second email. I tried both true and false.

Code: Select all

$email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
elseif (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) )
{

        $email_text_coupon .= EMAIL_WELCOME . EMAIL_TEXT_COUPON . EMAIL_CONTACT. EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT_COUPON, $email_text_coupon, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
Thanks JR
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Need Help To Use Else Function

Post by cpetercarter »

Do you mean

Code: Select all

ACCOUNT_COMPANY == 'true'
or

Code: Select all

ACCOUNT_COMPANY == true
They are not the same. The first tests whether ACCOUNT_COMPANY is a string 'true'. The second tests whether it has the boolean value true.
Post Reply