This topic is locked

Very silly newbie question

11/22/2006 10:35:19 AM
PHPRunner General questions
D
dwilliams author

Hi there
I have, what I hope will be, a very simple question: - I have created a simple form (within php runner) with the following fields:

  1. Name
  2. Email Address



What I want is for an email to be sent to the recipient in the Email Address field when the record is added(these fields will be part of a bigger form if I can get this to work). I have tried to play with adding an event (send simple email) after a record is added, but I don't know how to send the email to the required recipient which is pulled from the database.
I hope that makes sense, and I greatly appreciate any help on this.
Thanks,
Dave.

Sergey Kornilov admin 11/22/2006

Dave,
here is the example you can use. Make sure field name that stores email address is correct (in bold)

function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

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

$message="";

$subject="New data record";
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
}

D
dwilliams author 11/23/2006

Sergey,
Thank you so much for your help - works a treat <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13138&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
Best Regards,
Dave.