Write cover letter

In this section you will build the page that allows users write their cover letter online, and adds it in the database A database refers to data organized and stored on a computer that can be searched and retrieved by a computer program. Most industrial-strength and many smaller database applications can be addressed using SQL (Structured Query A query is a SQL command that will extract information from the tables of a database. Essentially, a query is a request for information from your database. Language).. Also, the form element that allows the user to actually write its letter will be a text-area enhanced with the KTML control, an online HTML editor. This way, the cover letter will not be in plain text format, but will be able to contain pictures and formatting.

Building this page is actually made up from two different actions:

  1. The first is to create the insert action, that will take user input and save it in the database.
  2. The second is to enhance the text area element used to write the letter, by replacing it with the KTML Lite control.

The steps to follow in order to create this page are as follows:

  1. Open the cover page from the user folder in Dreamweaver.
  2. Apply the Insert Record Form Wizard from the MX Kollection tab of the Insert panel. Configure it as shown below.
  3. In the first step set the table to insert into as cover_cvr, and the page to redirect The redirect server behavior loads a new site page after a transaction A transaction is a group of SQL statements whose effects are logically connected. Anything from simple queries to inserting, and deleting operations can be considered a transaction, as well as more complex groups of several statements which accomplish a specific task. is executed. For instance, users could be automatically redirected to their inbox after they log in to the website. will be the user's folder index:


                
  4. In the second one, a list of the fields that will appear on page is displayed: idusr_cvr and letter_cvr. You will have to change the properties for both of this elements, as follows:
    ·  For the idusr_cvr field, select the Text option in the Display as drop-down. This field stores the id of the user that wrote the letter, and as such it is safer to take it from the session A session is a way to preserve certain data across subsequent accesses of the same web application. The session object contains many variables to store user information on the web server in a location that you choose in special files. The session support allows you to register arbitrary numbers of variables to be preserved across requests. Sessions are specific to individual users. As a result, every user has a separate session and has access to a separate set of Session variables. variable. Simply hit the InterAKT dynamic data The InterAKT Dynamic Data tool is a replacement for the standard dynamic data dialog. It is used in the MX Kollection 3, to provide a unified way of building mark-ups, or place holders. These are recordset fields, server or session variables, and other types of dynamic data that are replaced at runtime by their corresponding values button (the blue lightning icon), and use the session variable kt_login_id. Then press OK to add it to the field:



    ·  For the letter_cvr field, set the Display as property to text area.


                        
  5. Now that you've set the properties for both fields, you can click the Finish button to exit the wizard and add all elements into the page.
  6. Remove the first row in the form, the one displaying the user ID. By removing it from the table, you do not remove it from the actual transaction, just from the HTML portion of the page.
  7. At this point you have a fully functional insert page, that allows a user enter a cover letter in plain text format, or even HTML, with all tags written by hand.

 

Now you will enhance the insert form, by replacing the standard text area with InterAKT's HTML editor, KTML. As mentioned in the beginning of this tutorial section, you have to download this extension, and install it.

Replacing the text area is a simple process, requiring only a small amount of actions:

  1. Select the text area in the page form.
  2. Apply the KTML Lite server behavior A server behavior is a reusable component for server-side development. They add blocks of code to your pages for accomplishing specific tasks. Dreamweaver comes with several default server behaviors and the InterAKT extensions add many more to this list.: in the server behaviors tab, click the Plus (+) button, then select KTML -> KTML Lite.
  3. When the KTML configuration dialog box opens, it will first ask if you want to check the InterAKT servers for a newer version. Assuming you've recently downloaded the extension, you can safely skip this step. Then define the correct options for your particular control: the folders for uploaded images and files, the toolbar buttons to display, the control's size etc:


                   
  4. For details concerning all of the interface's options, consult KTML's user manual. For the purpose of this tutorial, you can leave these options at their default.
  5. Once you click on the OK button, some files will be uploaded to your server, and you will notice that the page itself looks different. This is because the KTML control placed a translator instead of the regular text area:


                                                
  6. Now the page is completed, and you can save and access it in the browser, but only after you log on with a user account. You can compose a cover letter using complex formatting, such as tables, images, and when you hit the Insert Record button, it will save the HTML into the database, as in the example below:

 

Although you can now create a cover letter for the logged in users, the users cannot view what letters they have written and decide which to use. Also, this means that each user can enter several letters, without control. This section's purpose was to demonstrate the easy way to do things, and you can take it even further, by using a Content Management System for your site, as shown in this tutorial.