This topic is locked

Send Email Help Please

7/26/2010 3:47:07 AM
PHPRunner General questions
S
swanside author

Hello.

I have a table called query that has the following fields.

Query_Date, Customer_Name, Telephone_Number, Query_Content, Note_For.
The Note_For is selected from a dropdown which gets the name of the person from the login table and the field is Engineer_Name. In the login table it also has a field called email
When the project is built, if I add new on the query page enter the Query_Date, Customer_Name, Telephone_Number and Query_Content, then if I select somebody from the dropdown, I want this to send an email with the information from these fields in it.

Can this be done, and how please?

Thanks

Paul.

A
ann 7/26/2010

Paul,
use Send email with old data record predefined action in the After record added event on the Events tab.

Modify $email variable and fields selected for sending.

Here is just a sample:

global $conn,$strTableName;

$strTableName="query";

$email=$values["Note_For"];

$message="";

$subject="Sample subject";

$rs = db_query("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where ". $where,$conn);

if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$message.= $field." : ".$value."\r\n";

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $message));

}
S
swanside author 7/26/2010

Thanks Ann.

I tried this, but got this warning. Any ideas as to why please? I can not see the Send email with old data record only Send email with new data record

Thanks

Paul
php error happened
Technical information

Error type 8

Error description Undefined variable: where

URL 82.42.244.38/magic5test/query_add.php?

Error file D:\magic5test\include\query_events.php

Error line 22

SQL query insert into query (Query_Date, Customer_Name, Telephone_Number, Query_Content, Note_For) values ('2010-07-26', 'Test', '01234123345', 'Test Query', 'P.GRIMES')

// Place event code here.

// Use "Add Action" button to add code snippets.

global $conn,$strTableName;

$strTableName="query";

$email=$values["Note_For"];

$message="";

$subject="Sample subject";

$rs = db_query("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where ". $where,$conn);

if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$message.= $field." : ".$value."\r\n";

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $message));

}

A
ann 7/26/2010

Paul,
modify the code in the following way:

...

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where Id=". $keys["Id"]);

...



where Id is your key field name.

Here is an article:

http://xlinesoft.com/phprunner/docs/send_an_email_with_old_data.htm

S
swanside author 7/26/2010



Paul,
modify the code in the following way:

...

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where Id=". keys["Id"]);

...



where Id is your key field name.

Here is an article:

http://xlinesoft.com/phprunner/docs/send_an_email_with_old_data.htm


Thanks Ann. I take it this applies to the edit pages, where I am not using edit, just the Add Pages.

I have changed the line, but now I get this error
Parse error: parse error in D:\magic5test\include\query_events.php on line 24

// Place event code here.

// Use "Add Action" button to add code snippets.

global $conn,$strTableName;

$strTableName="query";

$email=$values["Note_For"];

$message="";

$subject="Sample subject";

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where Id=". keys["QueryId"]);

if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$message.= $field." : ".$value."\r\n";

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $message));

}

A
ann 7/26/2010

Paul,
you've not changed all key field names to the actual one.

Try this code:

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where QueryId=". $keys["QueryId"]);
S
swanside author 7/26/2010



Paul,
you've not changed all key field names to the actual one.

Try this code:

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where QueryId=". keys["QueryId"]);



Thanks. I now have this, but, when I press to check syntax, I get > syntax error, unexpected '[' in line 8


// Place event code here.

// Use "Add Action" button to add code snippets.

global $conn,$strTableName;

$strTableName="query";

$email=$values["Note_For"];

$message="";

$subject="Sample subject";

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where QueryId=". keys["QueryId"]);

if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$message.= $field." : ".$value."\r\n";

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $message));

}

A
ann 7/26/2010

Paul,
try this code:

$rs = CustomQuery("select Query_Date, Customer_Name, Telephone_Number, Query_Content from " . $strTableName ." where QueryId=". $keys["QueryId"]);



If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.