This topic is locked

Conditional email

6/1/2007 10:24:48 AM
PHPRunner General questions
W
wildwally author

I have searched and tried many versions of this with no luck, I am now asking for your help.
Based on what region was selected in the request sheet, I want an email sent to one of 3 people.

if ($Region = "Central")

{

$email="centraltest@test.com;

$message="New Bid Request Posted For the Central Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}

else if ($Region = "East")

{

$email="easttest@test.com

$message="New Bid Request Posted For the East Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}else ($Region = "West")

{

$email="westtest@test.com

$message="New Bid Request Posted For the west Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);


thanks for any help.

S
spoilar 6/1/2007

don't know if this is the problem, but try using the comparison operator ==
Like so

if ($Region == "Central")

{

$email="centraltest@test.com;

$message="New Bid Request Posted For the Central Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}

elseif ($Region == "East")

{

$email="easttest@test.com

$message="New Bid Request Posted For the East Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}else ($Region == "West")

{

$email="westtest@test.com

$message="New Bid Request Posted For the west Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}

W
wildwally author 6/1/2007

Nope still get "Parse error: syntax error, unexpected '{' in D:\Program Files\PHPRunner4.0\projects\myprojectname\_bid_request_events.php on line 42"
now i did notice some " & ; were missing after email names and fixed them. still no luck

S
spoilar 6/1/2007

try this

if ($Region == "Central"){

$email="centraltest@test.com";

$message="New Bid Request Posted For the Central Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}elseif ($Region == "East"){

$email="easttest@test.com";

$message="New Bid Request Posted For the East Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}elseif ($Region == "West"){

$email="westtest@test.com";

$message="New Bid Request Posted For the west Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}
W
wildwally author 6/1/2007

Getting closer i believe
error description: Undefined variable: Region
question I have this on the before record add. here is the whole code maybe this might help a little more.

function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into _activerequest (Request_Date, Quick_Pen_Due_Date, Region, Branch_Location, Store_Name, Store_Number, Store_Location, State, Branch_Manager, Email, Store_Type) values (

'".$values['Request_Date']."',

'".$values['Quick_Pen_Due_Date']."',

'".$values['Region']."',

'".$values['Branch_Location']."',

'".$values['Store_Name']."',

'".$values['Store_Number']."',

'".$values['Store_Location']."',

'".$values['State']."',

'".$values['Branch_Manager']."',

'".$values['Email']."',

'".$values['Store_Type']."'

)";

db_exec($strSQLInsert,$conn);
if ($Region == "Central"){

$email="centraltest@test.com";

$message="New Bid Request Posted For the Central Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}elseif ($Region == "East"){

$email="easttest@test.com";

$message="New Bid Request Posted For the East Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}elseif ($Region == "West"){

$email="westtest@test.net";

$message="New Bid Request Posted For the west Region.";

$subject="New Bid Request Posted";

mail($email, $subject, $message);

}
return true;
// return true if you like to proceed with adding new record

// return false in other case
}

Sergey Kornilov admin 6/1/2007

If Region is the field name you need to use $values["Region"] instead of $Region.

W
wildwally author 6/1/2007

That did it thanks for your help