close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Send email after insert into database using the MySQLi server behavior >>Data Management>>Insert Record

Thread began 10/24/2019 3:21 pm by sandy170299 | Last modified 10/29/2019 3:49 pm by Ray Borduin | 1208 views | 20 replies |

sandy170299

Send email after insert into database using the MySQLi server behavior >>Data Management>>Insert Record

How do I go about sending an email based on the data that was inserted using the MySQLi server behavior >>Data Management>>Insert Record?

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

You can apply the send email server behavior on the same page as the insert. Just remove the redirect from the insert and use the redirect in the send email so it has a chance to send. Then you can refer to the same form elements used in the insert for the email body.

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

Thanks, Ray. Using the Send Email option, I don't see the ability to choose which fields to include in the email. What am I missing? The insert script runs when the page loads, so I'm not sure what trigger to apply on the email script.

Here is my insert code and email code. It is inserting the transaction into the database, but the email isn't getting sent, and it's not redirecting.


<!-- ********************************************** -->
<!-- Insert Transaction in Transactions Table -->
<!-- ********************************************** -->
<?php
if ("" === "") {
$InsertQuery = new WA_MySQLi_Query($numeroseti);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "transactions";
$InsertQuery->bindColumn("toAcct", "i", "".$toAcct ."", "WA_DEFAULT");
$InsertQuery->bindColumn("fromAcct", "i", "".$fromAcct ."", "WA_DEFAULT");
$InsertQuery->bindColumn("toAcctNewBalance", "i", "".$toAcctNewBalance ."", "WA_DEFAULT");
$InsertQuery->bindColumn("fromAcctNewBalance", "i", "".$fromAcctNewBalance ."", "WA_DEFAULT");
$InsertQuery->bindColumn("amount", "i", "".$_SESSION["getRecipientAmount"] ."", "WA_DEFAULT");
$InsertQuery->bindColumn("description", "s", "".$_SESSION["description"] ."", "WA_DEFAULT");
$InsertQuery->bindColumn("timestamp", "s", "".$time ."", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>
<?php
if ("" === "") { //WA Universal Email
$Email = new WA_Email("transferaction");
$Email->Redirect = "http://numeroset.websailer.com/index.php";
$Email->From = "admin@websailer.com";
$Email->addTo("".($getRecipient->getColumnVal("user_email")) ."");
$Email->BodyFile = "webassist/email/templates/WebAssist-Block/Block_3.php";
if (function_exists("rel2abs") && $Email->Redirect) $Email->Redirect = $Email->Redirect?rel2abs($Email->Redirect,dirname(__FILE__)):"";
for ($emailGroup=0; $emailGroup<sizeof($Email->To); $emailGroup++) {
$Email->Subject = "Transaction Receipt";
$Email->send($emailGroup);
}
$Email->close();
}
?>

Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the page so I can open it in dreamweaver when you want me to look at your code.

I think the redirect isn't working because of the html comment above the php code. Any html above a redirect would cause the redirect to not work. I think you can just wrap it in a php comment if you want to leave the comment there, so instead of:

<!-- ********************************************** -->
<!-- Insert Transaction in Transactions Table -->
<!-- ********************************************** -->



use:

php:
<?php

/*
********************************************** 
Insert Transaction in Transactions Table 
********************************************** 
*/
?>



The email not sending may be because of the getRecipient recordset not returning a result.

To get access to the form elements from the insert page in the email body. Just open up the email body page and go to the bindings panel. Then click the plus button and select "Form Data" and choose the insert page. That will make all of the form elements from the insert page available in the bindings for the email body.

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

"Just open up the email body page and go to the bindings panel."

I get an error that says, "no forms were found on the page......" This because there IS no form on the action page. The data is being carried over from a previous page. I will attach my page for you. No email errors this time, but I haven't received the email yet. Just ignore all of the comments in the page - I needed to make sure all the data was transferring forward.

Also, transID field is an auto increment field. Not sure how that is going to play into this. Would I first need to create a query to grab the last transID?

Thank you.

Attached Files
transferaction.zip
Sign in to reply to this post

Ray BorduinWebAssist

Choose the form page you want the bindings from. Not the action page if it is different.

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

I added this code to the transferaction.php page: <?php
$last_id = mysql_query("SELECT `transID` FROM transactions ORDER BY `transID` DESC LIMIT 1");
?>

Then, on Block_3.php, these are my bound fields:

<tr valign="top">
<th style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;width: 134px; text-align: right; padding: 3px 10px 3px 3px; color: #666; font-weight: bold;">Transaction ID:</th>
<td style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;padding: 3px; border-left: 1px solid #DDD; color: #B6B6B6;">
<?php echo $last_id; ?>
</td>
</tr>
<tr valign="top">
<th style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;width: 134px; text-align: right; padding: 3px 10px 3px 3px; color: #666; font-weight: bold;">Description:</th>
<td style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;padding: 3px; border-left: 1px solid #DDD; color: #B6B6B6;">
<?php echo((isset($_POST["description"]))?$_POST["description"]:"") ?></td>
</tr>
<tr valign="top">
<th style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;width: 134px; text-align: right; padding: 3px 10px 3px 3px; color: #666; font-weight: bold;">Amount:</th>
<td style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;padding: 3px; border-left: 1px solid #DDD; color: #B6B6B6;">
<?php echo((isset($_POST["amount"]))?$_POST["amount"]:"") ?></td>
</tr>
<tr valign="top">
<th style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;width: 134px; text-align: right; padding: 3px 10px 3px 3px; color: #666; font-weight: bold;">From Account:</th>
<td style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;padding: 3px; border-left: 1px solid #DDD; color: #B6B6B6;">
<?php echo $_SESSION['acct_number']; ?>
</td>
</tr>
<tr valign="top">
<th style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;width: 134px; text-align: right; padding: 3px 10px 3px 3px; color: #666; font-weight: bold;">To Account:</th>
<td style="font-family: Verdana, Geneva, sans-serif; font-size: 10px;padding: 3px; border-left: 1px solid #DDD; color: #B6B6B6;">
<?php echo $_SESSION['racct_number'] ?>
</td>
</tr>

It's still not sending this email, however.

Sign in to reply to this post

sandy170299

There was a typo in the email address. Sorry! However, the body of the email is not getting included with the email itself. I am going to attach the 3 pages that should be involved with this process. There's one page I excluded - let me know if you want that one as well.

Just to clarify, the email IS getting sent now - just missing all body content.

Sign in to reply to this post

Ray BorduinWebAssist

The only reason that I can think of that the email body would be blank is if you didn't upload the Block_3.php email body file. I'd need FTP access and a URL to reproduce to debug this one. I can't spot the issue with the files themselves.

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

The email template IS on the sever. Please see the PM for my FTP info.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...