This topic is locked

Emaill all fileds within an add or edit form to user with email link b

4/23/2007 10:05:40 AM
PHPRunner General questions
K
kwebb author

I have created a function within the Events "Add page/Before record added" which will send an email to a User with the content of the fields included in the email.
I would like to include a mechanism within this email to include a LINK back to the edit page of this ticket/form. Much like a standard capability of a problem ticketing system.
Does anyone have any experience with this?
Here is my function within the "Add page/Before record added" events page:
function BeforeAdd(&$values)

{

global $conn;

// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Send email with new data ****
$message="";

$subject="A new task has been assigned to you...";
//select user email from _users

$str = "select * from _users where LoginName = '".$_SESSION["UserID"]."'";

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

$data = db_fetch_array($rs);

$useremail = $data["email"];

$email=$useremail;
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n";
mail($email, $subject, $message);
return true;
// return true if you like to proceed with adding new record

// return false in other case
}

J
Jane 4/24/2007

Try to use following code:

...

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

$message.= $field." : ".$value."\r\n";
$message.="<a href=\"http://hostname.com/phprunner/TableName_edit.php?editid1=".postvalue("editid1")."\">Link to the edit page</a>";

...

K
kwebb author 4/24/2007

Thanks Jane, This got me much closer...
Your suggestion works if I use it in the "Edit page/Before record updated"

results:

"http://flcad5/cwip/_tasklist_edit.php?editid1=86";
but within the "Add page/Before record added" .postvalue isn't returning the value.

results:

"http://flcad5/cwip/_tasklist_edit.php?editid1=";
Is the .postvalue available for retrival at the "Add page/Before record added" state? or would this need to be done in the "After record added" state?

J
Jane 4/25/2007

Hi,
if your primary key is auto-increment field you need to use After Record added event to select id of last inserted record. Here is a sample code:

...

$id = mysql_insert_id();

$message.="<a href=\"http://hostname.com/phprunner/TableName_edit.php?editid1=".$id."\">Link to the edit page</a>";

...

K
kwebb author 4/25/2007

Thanks Jane..... That worked!
I was not aware of this postvalue function..... Is there listing somewhere on these type of PHPR functions?

How does one go about finding these very useful and powerful features?

J
Jane 4/26/2007

Hi,
some PHPRunner variables you can find in the PHPRunner Help:

http://www.xlinesoft.com/phprunner/docs/mo...bout_events.htm
Also you can find all PHP functions in the PHP documentation:

http://php.net/manual/en/