Include a Master Form V4 Database in a Web Page
You've got information that is written to a database from your Master Form V4 program. You would like for that information to appear on a web page. But how do you get it to appear within a web page that matches the look and feel of the rest of your website? The solution can be had by using one of three options: JavaScript, PHP, or SSI.
JavaScript
The first step is to create a form that will collect the information you want written to a database. Once you create the Master Form V4 form, create two hidden form fields, the filetemplate and dbfile:
<input type="hidden" name="filetemplate" value="mf4/subdirectory/webpagedbTemplate.txt">
This file is located in a subdirectory of your Master Form V4 installation.
<input type="hidden" name="dbfile" value="/subdirectory/webpagedbinfo.js">
This can be anywhere on your server. This is the file that will be included within the web page.
In this example, the web page includes a table with the information from the database.
The first thing we do is format a filetemplate so that it will fit into the shell of the web page.
Because we are using a table in this example, we will separate our form fields using the td tag:
<td>[[formfield1]]</td> <td>[[formfield2]]</td> <td>[[formfield3]]</td>
This is a JavaScript file, so there is one more step to creating the template and that is convert it from text to JavaScript. Click here for a handy tool to do that.
It will look like this:
document.writeln('<td>[[formfield1]]</td>');
document.writeln('<td>[[formfield2]]</td>');
document.writeln('<td>[[formfield3]]</td>');
Save this as webpagedbTemplate.txt and upload to the folder as indicated in the filetemplate hidden field.
Here is the shell for the web page with the JavaScript File:
<html> <head> <title>Web Page With A Database Example</title> </head> <body> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>Form Field 1 Title</td> <td>Form Field 2 Title</td> <td>Form Field 3 Title</td> </tr> <tr> <script type="text/javascript" language="JavaScript" src="https://YourDomain.com/subdirectory/webpagedbinfo.js"> </script> </tr> </table> </body> </html>
PHP
Before proceeding with the PHP example, please read this article on how to run PHP on non-PHP web pages.
The first step is to create a form that will collect the information you want written to your database. Once you create your Master Form V4 form, we will create two hidden form fields, the filetemplate and dbfile:
<input type="hidden" name="filetemplate" value="mf4/subdirectory/webpagedbTemplate.txt">
This file is located in a subdirectory of your Master Form V4 installation.
<input type="hidden" name="dbfile" value="/subdirectory/wepagedbinfo.html">
This can be anywhere on your server. This is the file that will be included within the web page.
In this example, the web page includes a table with the information from the database.
The first thing we do is format a filetemplate so that it will fit into the shell of the web page.
Because we are using a table in this example, we will separate our form fields using the td tag:
<td>[[formfield1]]</td> <td>[[formfield2]]</td> <td>[[formfield3]]</td>
Save the above as webpagedbTemplate.txt and upload to the folder as indicated in the filetemplate hidden field.
Here is the shell for the web page with the PHP File:
<html>
<head>
<title>Web Page With A Database Example</title>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>Form Field 1 Title</td>
<td>Form Field 2 Title</td>
<td>Form Field 3 Title</td>
</tr>
<tr>
<?php
@readfile("/subdirectory/webpagedbinfo.html");
?>
</tr>
</table>
</body>
</html>
SSI
The first step is to create a form that will collect the information you want written to your database. Once you create your Master Form V4 form, we will create two hidden form fields, the filetemplate and dbfile:
<input type="hidden" name="filetemplate" value="mf4/subdirectory/webpagedbTemplate.txt">
This file is located in a subdirectory of your Master Form V4 installation.
<input type="hidden" name="dbfile" value="/subdirectory/webpagedbinfo.txt">
This can be anywhere on your server. This is the file that will be included within the web page.
In this example, the web page includes a table with the information from the database.
The first thing we do is format a filetemplate so that it will fit into the shell of the web page.
Because we are using a table in this example, we will separate our form fields using the td tag:
<td>[[formfield1]]</td> <td>[[formfield2]]</td> <td>[[formfield3]]</td>
Save the above as webpagedbTemplate.txt and upload to the folder as indicated in the filetemplate hidden field.
Here is the shell for the web page with the SSI File:
<html> <head> <title>Web Page With A Database Example</title> </head> <body> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td>Form Field 1 Title</td> <td>Form Field 2 Title</td> <td>Form Field 3 Title</td> </tr> <tr> <!--#include file="/subdirectory/webpagedbinfo.txt"--> </tr> </table> </body> </html>
There you have it. Three efficient ways to include your Master Form V4 created databases within your web pages. This example is more suited for small databases and tabular data, but you can use html code to structure the information as you want it presented.
Jackie McCutcheon

