
Solid, safe website tools.
Whatever your need, Will Bontrager builds powerful software solutions.
If you don't find the answer to your question in these archives, ask your CGI question at the Current Master Series CGI Forum.
Does this page provide information you can use?
How can it be improved?
Your comment is anonymous.
When done typing, click anywhere outside the box. [more info]
| Author | Message |
|---|---|
| 25Aug05 Joyce Moss |
Subject: auto-attaching a dbase record file to an email I have MasterFormV4 set up to generate & send submitted form input in an email, & add a database record to a database on server. Want the script [or a script] to automatically attach the generated database record to the email. |
| 25Aug05 Will [Email] ![]() |
In response to: auto-attaching a dbase record file to an email Joyce, put the [[ATTACH ...]] placeholder into the body content area of the email template. The format can be any of the following: [[ATTACH http://example.com/file.txt]] [[ATTACH /document/root/path/file.txt]] [[ATTACH /file.txt]] [[ATTACH subdirectory/file.txt]] If using http://... URLs, the URL must be something browsers can access without requiring password or security tokens, in other words, a public URL. Note that the database is updated after the email is sent. If you want a copy of the database, complete with the update caused by the current form submission, rearrange three lines in the MasterFormV4.cgi script. These three lines:
SendTheEmail unless $In{exitnow};
StoreUploadedFiles unless $In{exitnow};
UpdateDatabases unless $In{exitnow};
will need to be
UpdateDatabases unless $In{exitnow};
SendTheEmail unless $In{exitnow};
StoreUploadedFiles unless $In{exitnow};
Rearranging like that could cause the database to be updated even if there is some kind of error that won't let the emails be sent. If that's acceptable, the above rearrangement of the three lines should work just fine. |
| 25Aug05 Joyce Moss |
In response to: auto-attaching a dbase record file to an email MasterForm is an elegant thing! ...but it does take a bit of study.I have to study your answer a bit. I want to attach a file that is just the record of that one entry - so is there a way to generate a file of just each individual form enty - just the one record? |
| 25Aug05 Joyce Moss |
In response to: auto-attaching a dbase record file to an email hint for solving next step may be: if/when database file is deleted, the next dbase entry makes a dbase file. This could get to be fun... joyce |
| 26Aug05 Joyce Moss |
In response to: auto-attaching a dbase record file to an email Yipes! but I got my form like I want it. |
| 26Aug05 Will [Email] ![]() |
In response to: auto-attaching a dbase record file to an email No problem re repetitive posting of the same post. The repeats have been removed. With the control panel, that part is quick and easy. That's something I should add in this forum software, the ability to detect repetitive posts. But it seems I've always got stuff to do for customers and other things for ourselves, and don't get around to it. The "cobbler's kids have no shoes" syndrome. I'm glad you got your form working the way you want. I'll respond anyway, for those who may read this thread with similar questions. The way to cause a new file to be created every time the database is updated is to put this as the first line of the database template file: **OVERWRITE_FILE** Every time the database is updated, the previous data is overwritten. Depending on the speed of your server, it probably takes less than a second to write the file and send the email. If you need to keep the data on the server, or if you think it's possible the same form will be submitted by two or more people during the same second of time (which could cause the wrong data to be attached), then a different file needs to be created every time the form is used. There are various ways to cause a different database file name to be created every time the form is used. Probably the most common is to use the server system time as part of the file name. The system time changes 100 times a second. If the form is submitted by more than one person and processed by the server in the same hundredths of a second, then one would be overwritten (if the above "overwrite" directive is used) or appended. If protection from even that is desired, a form field value can also be used in the database file name. It should be a field that's filled in every time, email address for example. To accomplish it, both the file name specified in the form and the file name specified for the attachment need to have identical placeholders. Example form field: <input type="hidden" name="dbfile" value="data/[[email]]_[[SYSTEMTIME]].txt"> Example attachment placeholder for the email template file: [[ATTACH data/[[email]]_[[SYSTEMTIME]].txt]] When a new database file is created with every form use, older files may need to be removed from the server periodically, especially if the form is popular. As an aside, there's lots of other goodies in the "Database Files" section of the Master Form V4 manual how to make the first database record hold the column names, for example. |