Send form results to your database & email…
This example provides a “hack”** method of sending to both your database and an email address using the tools within FrontPage…
FrontPage does not currently have the capability to do this so the following example was developed to illustrate one method that can be used. However, we highly recommend the use of ASP email components or CDONTS over this method (click here for more information on the CDONTS method). This method, while good for those who do not know how to or don’t want to write code, requires that the user click a submit button twice. The first time sends the form information to a page that writes the information to the database and the second sends the form through the FrontPage form handler to send the email. Good Luck!
This process requires three pages and one optional page.
Develop a page called, for this example, Form.htm.
On this page you will place a form with the information that is to be submitted to a database.
For this example, use only one text box. (First Name)
Develop a second page called Form.asp.
This page updates the database
Develop a third page called Email.htm.
This page will be included in Form.asp, which will contain the form information to submit the email.
The optional page is a confirmation page.
1. Launch FrontPage and open a web
2. Create a new page and save it as Form.htm
3. Create another new page and call it Form.asp
4. Create another page and call it Email.htm
5. Return to Form.htm and click on Insert | Form | One Line Text Box
6. Double-click the text box and name the field “fname” without the quotes and click OK
7. Right-click on the form and select Form Properties
8. Click Send to Other and be sure it says Custom ISAPI, NSAPI, CGI, ASP…. then click Options
9. In the Action type “Form.asp” without the quotes and be sure it says “Post”
10. Click OK twice to get back to the page
11. Type “First Name:” next to the text box and save the page
12. Go to Email.htm
13. Click on Insert | Form and then type something like “Thanks for submitting the info, click Submit to continue.” (it is very important that they click submit)
14. Right-click the form and go to Form Properties
15. Click Send To: and type in the email address
16. Click Advanced
17. Click Add to add a hidden field
18. Name this field “fname” without the quotes
19. Type the following code into the value box <%=request.form("fname")%>
20. Click OK twice to get back to the page
21. Save the page
22. Now go to Form.asp and hit enter twice then click on Insert | Component | Include Page and type Email.htm into the box; click OK
23. Click at the top of the page and click on Insert | Database | Results
24. On Step One choose your database connection
25. On Step Two click Custom Query and type this SQL statement: INSERT INTO table (firstname) Values (‘::fname::’) NOTE: The statement should be changed so that “table” states the actual table name, and “firstname” is a column value in the database. Notice that fname is the form field name from Form.htm. It is good practice to have your form field names match your database table names.
26. In Step 3, under More Options, make sure you assign default values for each field name and make sure that you erase the message No Records Returned.
27. Click through the rest of the defaults, click Finish and save the page.
28. OPTIONAL: Make a page called Confirm.htm
29. In Confirm.htm you can type in a confirmation message with links that will take you back to Form.htm or any other page on your site.
30. Open Email.htm
31. Right click the form and go to properties
32. Click Options | Confirmation Page | URL of Confirmation Page type Confirm.htm
33. OK twice
34. Save the page (Email.htm)
Go back to Form.htm and give it a test.
Keep in mind that whatever you wish to send to the database, needs to be on Form.htm before you do anything else.
SQL hint: If you would like to send additional data, you will need to modify the SQL statement as follows:
INSERT INTO table (firstname, lastname) Values (‘::fname::’, ‘::lname::’)
These are the column names in the table. These are the form field names from your form. They may not match depending on your naming scheme.
** So why do we call this a “Hack” method? The FrontPage server extensions are actually not supposed to allow this behavior.