close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to include database data within the e-mail receipt AND carry over form data?

Thread began 8/27/2015 1:49 am by Nathon Jones Web Design | Last modified 8/31/2015 12:18 pm by Ray Borduin | 1237 views | 7 replies |

Nathon Jones Web Design

How to include database data within the e-mail receipt AND carry over form data?

I'm using the WebAssist > Create Email Message behaviour to send an e-mail to the customer on completion of an UPDATE form.

The UPDATE form simply changes one of the product's values in the product table whereas the rest of the form is the customers contact details.

I am carrying over product data in the redirect section of the UPDATE behaviour to my confirmation page (on which Universal Email resides) as follows:

$UpdateGoTo = "reserve-whisky-cask-confirm.php?wbid=".($rsCASKINFO->getColumnVal("wbprodID"))  ."&cask=".($rsCASKINFO->getColumnVal("wbprodTITLE"))  ."&caskno=".($rsCASKINFO->getColumnVal("wbprodCASKNO"))  ."&caskprice=".($rsCASKINFO->getColumnVal("wbprodPRICE"))  ."";



What I'd like to do is just carry over the product ID so that I can create a recordset on the confirmation page AND include data from that recordset in the Universal Email email that's sent out. I'm using a separate file, reservecaskreceipt.php, as the template for the Universal Email body.

I can create the recordset on the confirmation page but when I include database data in reservecaskreceipt.php I get the following error:

Notice: Undefined variable: rsCASKINFO in /home/linweb39/n/nathonjoneswebdesign.co.uk/user/htdocs/whiskybroker/reservecaskreceipt.php on line 18

Fatal error: Call to a member function getColumnVal() on a non-object in /home/linweb39/n/nathonjoneswebdesign.co.uk/user/htdocs/whiskybroker/reservecaskreceipt.php on line 18



So I assumed that I'd need to include the database connection script and recordset on the reservecaskreceipt.php page too:

<?php require_once('Connections/csdbmysqli.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php
$rsCASKINFO = new WA_MySQLi_RS("rsCASKINFO",$csdbmysqli,1);
$rsCASKINFO->setQuery("SELECT wbprodID, wbprodTITLE, wbprodPRICE, wbprodCASKNO FROM WBproducts WHERE wbprodID = ?");
$rsCASKINFO->bindParam("i", "".(isset($_GET['wbid'])?$_GET['wbid']:"") ."", "-1"); //WAQB_Param1
$rsCASKINFO->execute();
?>



However this then produces the following error:

Notice: Undefined variable: csdbmysqli in /home/linweb39/n/nathonjoneswebdesign.co.uk/user/htdocs/whiskybroker/reservecaskreceipt.php on line 4

Fatal error: Call to a member function Prepare() on a non-object in /home/linweb39/n/nathonjoneswebdesign.co.uk/user/htdocs/whiskybroker/webassist/mysqli/rsobj.php on line 155



...and I reach a dead end on this part of it. :(

However, I also need to carry over the remaining form data - the customers contact information - so that it's included in the Universal Email body and had the following within my reservecaskreceipt.php template page:

<?php echo((isset($_POST["resvcaskNAME"]))?$_POST["resvcaskNAME"]:"") ?>
<?php echo((isset($_POST["resvcaskNAME"]))?$_POST["resvcaskPHONE"]:"") ?>
<?php echo((isset($_POST["resvcaskNAME"]))?$_POST["resvcaskEMAIL"]:"") ?>



...etc.

But these values do not appear to be carried over from the UPDATE form. If it's just a standard form-to-email then it works but I'm assuming that it doens't because I'm using an UPDATE form and in the process of doing the UPDATE it wipes the form values?

...again I reach a dead end.

How do I include recordset data AND the submitted form data on my reservecaskreceipt.php template page?
Much appreciated.
NJ

Sign in to reply to this post

Nathon Jones Web Design

So I trawled through the forum here and added this to the top of my reservecaskreceipt.php template page:

<?php
global $rsCASKINFO;
?>



rsCASKINFO being the recordset that's on my confirmation page.

I can now include recordset data in my Universal Email email body:
<?php echo($rsCASKINFO->getColumnVal("wbprodTITLE")); ?> ...etc.

Bingo! However I still can't seem to carry over the remaining form data - the customer's contact details:
<?php echo((isset($_POST["resvcaskNAME"]))?$_POST["resvcaskNAME"]:"") ?> ...etc.

Will keep trawling but if anyone has an answer to this I'd really appreciate it. Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Post data is always global. Are you sure you are using the correct form element names? Is your form method="post" ? is the form submitting directly to the page that sends the email without redirecting to it?

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

Nathon Jones Web Design

Yes, I'm sure of that.

The form has Server Validation on it, on the same page, because it's an UPDATE form and I've made sure that the Server Validation behaviour code is above the UPDATE behaviour code so that it runs before the UPDATE occurs.

The form isn't submitting directly to the page that sends the e-mail because it's doing a Server Validation and an UPDATE first, and then redirecting, via the UPDATE behaviour, to the page that sends the e-mail which I've simplified to:

$UpdateGoTo = "reserve-whisky-cask-confirm.php?wbid=".($rsCASKINFO->getColumnVal("wbprodID"))  ."";



I attach three pages.
reserve-whisky-cask.php - the page with the form
reserve-whisky-cask-confirm.php - the page that the UPDATE behaviour directs to.
reservecaskreceipt.php - the email template

Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Get rid of the redirect on update and add the email server behavior to that page and redirect after the email is sent instead. That way the form post will be available in the email body.

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

Nathon Jones Web Design

Done...and now the form post data doesn't display the form post information on the confirmation page. See attached. :(

Sign in to reply to this post

Ray BorduinWebAssist

Form data is only available on the page specified as the action page of the form.

If you want to persist form data across a redirect you can use the webassist "Persist Form" server behavior to store it into the session.

Another option would be to apply the Validation, Update and email server behaviors on the confirm page and update the form action to submit to that page directly.

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

Nathon Jones Web Design

Originally Said By: Ray Borduin
  Another option would be to apply the Validation, Update and email server behaviors on the confirm page and update the form action to submit to that page directly.  



This fixed it. Thank you Ray.
NJ

Sign in to reply to this post

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...