Page 1 of 1

Adding variables with if command... [SOLVED]

Posted: Fri Apr 11, 2008 2:00 pm
by eymorais
Here's the current situation...

I've got a form, form.php, that submits variables to a swift mail handler. The variables are then added to a text/html mime email and sent to a client and Bcc'd to myself.

The only thing is that if I select a package (ie: Pckg1), I want 2 associated values (Value1B & Value1C) supplied automatically to the HTML email template.

I've currently got the following coding in my PHP script, but the template doesn't show the additional values....

Code: Select all

 
//Package Variables
$package = $_POST["comment_pckg"];
 
if ( $package == "Pckg1" ) {
    $size_en == "Value1B";
    $size_fr == "Value1C";
}
elseif ( $package == "Pckg2" ) {
    $size_en == "Value2B";
    $size_fr == "Value2C";
 
}
else ( $package == "Pckg3" ) {
    $size_en == "Value3B";
    $size_fr == "Value3C";
}
 

Re: Adding variables with if command...

Posted: Fri Apr 11, 2008 6:19 pm
by micknc
The variables do not need two equals signs.

Code: Select all

 
//Package Variables
$package = $_POST["comment_pckg"];
 
if ( $package == "Pckg1" ) {
    $size_en = "Value1B";
    $size_fr = "Value1C";
}
elseif ( $package == "Pckg2" ) {
    $size_en = "Value2B";
    $size_fr = "Value2C";
 
}
else ( $package == "Pckg3" ) {
    $size_en = "Value3B";
    $size_fr = "Value3C";
}

Re: Adding variables with if command...

Posted: Fri Apr 11, 2008 6:29 pm
by John Cartwright
== and === are comparison operators, whereas a single = is an assignment operator

Re: Adding variables with if command...

Posted: Mon Apr 14, 2008 7:00 am
by eymorais
Worked like a charm. Thanks for the help!