This topic is locked

Email after record added

10/22/2008 10:27:02 AM
PHPRunner General questions
K
Khris author

I'm setting up an online Support Queue where users can submit requests and then track online. As soon as they enter a request (After Record Added Event), I'm using the following code to send them a copy of the information to keep for their records. The problem I'm having is that somtimes the wrong information is emailed out. I think it's because I need a WHERE statement on my database query to limit it only to the record that was just added.

global $conn;
$message="";
$str="

SELECT

QueueID,

`Submitted By`,

Telephone,

Email,

`Problem Area`,

`Problem Type`,

Description,

`Submitted On`

FROM queue

";
$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
$message.="QueueID : ".$data["QueueID"]."\r\n";

$message.="Submitted By : ".$data["Submitted By"]."\r\n";

$message.="Telephone : ".$data["Telephone"]."\r\n";

$message.="Email : ".$data["Email"]."\r\n";

$message.="Problem Area : ".$data["Problem Area"]."\r\n";

$message.="Problem Type : ".$data["Problem Type"]."\r\n";

$message.="Submitted On : ".$data["Submitted On"]."\r\n";

$message.="\r\n";

$message.=$data["Description"]."\r\n";

$message.="\r\n";

$message.="\r\n";

$message.="\r\n";

$message.="**Please keep this email for your records.";

$message.="\r\n";
$email=$data["Email"];

$subject="New Support Request #".$data["QueueID"]." Entered. - ".$data["Problem Area"]." / ".$data["Problem Type"];
mail($email, $subject, $message);
J
Jane 10/23/2008

Hi,
all entered values are stored in the $values array.

Use $values instead of $data in your code:

$message="";

$message.="QueueID : ".$values["QueueID"]."\r\n";

$message.="Submitted By : ".$values["Submitted By"]."\r\n";

$message.="Telephone : ".$values["Telephone"]."\r\n";

$message.="Email : ".$values["Email"]."\r\n";

$message.="Problem Area : ".$values["Problem Area"]."\r\n";

$message.="Problem Type : ".$values["Problem Type"]."\r\n";

$message.="Submitted On : ".$values["Submitted On"]."\r\n";

$message.="\r\n";

$message.=$values["Description"]."\r\n";

$message.="\r\n";

$message.="\r\n";

$message.="\r\n";

$message.="**Please keep this email for your records.";

$message.="\r\n";
$email=$values["Email"];

$subject="New Support Request #".$values["QueueID"]." Entered. - ".$values["Problem Area"]." / ".$values["Problem Type"];
mail($email, $subject, $message);

K
Khris author 10/23/2008

Thank you again Jane!
Can you give me an example of when I would use $data instead? (mainly so I can understand the difference)

J
Jane 10/24/2008

Khris,
check parameters in the event headers.

You can use $data in the List page: After record processed, Before register, etc.