This topic is locked

Would Like to Create an email Event for a specific Field

1/5/2007 7:33:37 AM
PHPRunner General questions
N
Norian author

Hello,
I would like to start off by saying tht I am very new to PHP & MySQL. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=4305&image=1&table=forumtopics' class='bbc_emoticon' alt=':rolleyes:' />
I currently have a need of creating a phone log application and need to be able to automatically generate an email to be sent if an urgent call back is required.
So far I have the table Phone Log with the following fields:
ID

Engineer

Time of Call

Callers Name

Company

Origin

Subject

Related Ticket Number

Callers Email

Callers Phone

Who Is the Call For

Urgent Call Back
I would like to be able to generate an email if urgent call back is yes on the form I have set this to a box with yes or no options
If urgent call back is yes then I would like the email to be generated along the lines of
Please can "who is the call for" contact "Callers Name"
So far I have been trying to use the code I tried to adapt from another post ...

function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//********** Custom code ************

// put your custom code here

if $values["Urgent Call Back"] = "yes" {
$email = "email@email.com";

$subject = "Phone Messaging System: Urgent Call Back Required";

$message = "An urgent call back has been requested" . "\n\n";

$message .= "Please can: " . $values["Who is the call for"] . "\n";

$message .= "Call: " . $values["Callers Name"] . "\n";

$message .= "Thank you.";
mail($email, $subject, $message);
}
return true;
// return true if you like to proceed with adding new record

// return false in other case
}



But I am just getting errors when I try and go to the page from the menu
Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /var/www/dev/php/include/_Phone_Log_events.php on line 13
Any help would be greatly appreciated and many thanks in advance

T
thesofa 1/5/2007

Hello,

//** Custom code ****

// put your custom code here

if $values["Urgent Call Back"] = "yes" {
But I am just getting errors when I try and go to the page from the menu
Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /var/www/dev/php/include/_Phone_Log_events.php on line 13
Any help would be greatly appreciated and many thanks in advance



the clue is in the

expecting '('

part of the message, it is looking for a pair of parentheses in the 'if' clause

you may want to change this part to read as follows
//** Custom code ****

// put your custom code here

if ($values["Urgent Call Back"]= "yes") {



I think you need the parentheses around the condition for the if clause.

Also, a=b makes a have the same value as b

a==b checks if a has the same value as b

so the line should be as follows
//** Custom code ****

// put your custom code here

if($values["Urgent Call Back"]== "yes") {


If you are new to php, this site may be really useful for you to bookmark.

HTH

N
Norian author 1/5/2007



the clue is in the

part of the message, it is looking for a pair of parentheses in the 'if' clause

you may want to change this part to read as follows
//** Custom code ****

// put your custom code here
I think you need the parentheses around the condition for the if clause.

Also, a=b makes a have the same value as b

a==b checks if a has the same value as b

so the line should be as follows
//** Custom code ****

// put your custom code here
If you are new to php, this site may be really useful for you to bookmark.

HTH


Hello thanks for the quick response.
This has fixed the problem with the error however no email i being generated. I think it might be down to that I havent got the right values. I am using the control field for the values, or should I be using something else?
Many thanks and sorry for being daft as a brush <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14293&image=1&table=forumreplies' class='bbc_emoticon' alt=':unsure:' />

N
Norian author 1/5/2007

I figured it out... many thanks for the initial help <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=14294&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

if ($values['Urgent Call Back'] =="Yes") {
$email = "email@email.com";

$subject = "Phone Messaging System: Urgent Call Back Required";

$message = "An urgent call back has been requested" . "\n\n";

$message .= "Please can: " . $values['Who is the call for'] . "\n";

$message .= "Call: " . $values['Callers Name'] . "\n";

$message .= "Contact Number: " . $values['Callers Phone'] . "\n";

$message .= "\n Thank you. \n The Phone Messaging System";
mail($email, $subject, $message);
}