baserunner
contents    queries
configuration templates
expressions sessions
databases data entry
passwords email
license support

Data Entry and Editing

The data entry and data editing functions use HTML forms to gather the data to be added or changed. The fields in the form use the same names as fields in the database. For editing data, you will need to add the values from the various database fields to the form fields. You may also enter default values (directly or from the current record) to the form fields for data entry. The only difference between these actions is that entry appends a new record and edit inserts data into the current record.

<input type="checkbox" name="logic_field" value="T">

If you are editing data you will want to provide for both true and false entries:

<input type="radio" value="T"
{iif(log_field=.T.,'checked','        ')} name="log_field"> Yes
<input type="radio" value="F"
{iif(.NOT.log_field,'checked','        ')} name="log_field"> No

You may include calculated values (or other expressions) in the entry or edit forms. To accomplish this, add a "%" sign to the beginning of the field name. These expressions are parsed after the users entries are made, so those values are available to these expressions. Normally, these should be hidden fields. In the example application, the logical field blk_wht is set to .TRUE. if the value of the rating field is "R."

<input type="hidden" name="%blk_wht" value="(rating='R')">

This entry from the example application, evaluates the expression "rating='R'", which either evaluates to .TRUE. or .FALSE., and set the value of the logic field blk_wht accordingly. (This is a completely arbitrary example since there have been a number of R rated movies produced in color.)

For both entry and editing, blank entries fields from the user are ignored (i.e. when editing a record, if the user submits a blank value, no change will be made to that field).

baserunner does no validation on a user's entries. For instance, if a user enters more text than a field can hold, baserunner will simply truncate the entry; or if a user enters data that cannot be placed in a field, e.g. a date in the wrong format, baserunner will simply ignore it. You may supply a JavaScript to do any necessary validation for the entry or edit form.

Three logical variables are available that affect how character data is entered into the database (character or memo fields):

_striphtml If this variable is set, all HTML code submitted will be deleted before the data is added to the database. This is done with a fairly brute force method: all text contained within < > symbols is deleted.
_modhtml If this variable is set, all instances of the < symbol will be changed to &lt; and all instances of the > symbol will be changed to &gt;, rendering the HTML tags as normal text.

If you choose to allow HTML code to be entered by the user, please recognize that this can raise security issues. HTML code can be used maliciously.

With memo fields, because of the way line breaks are handled between the memo file and HTML, some formatting problems can occur. Particularly, in fields that are repeatedly modified, addition carriage return characters may appear making editing the field contents difficult. How line breaks are transmitted from a form to baserunner is dependant on the WRAP value in the <textarea> tag. You have four options for handling memo field values: The first is to do nothing at all, which in many cases may be the best. Or, you may use a _stripreturns variable with the form. _stripreturns may have three values:

_stripreturns=X Using this form, _stripreturns acts as a logical variable. The value may be anything at all, as long as it has a value. baserunner will remove all carriage return (\r) characters from the entry, leaving in place new line characters (\n).
_stripreturns=all If _stripreturns is given the value "all," carriage return characters will be deleted, and new line characters will be changed to spaces.
_stripreturns=htmlbreak If _stripreturns is given the value "htmlbreak," carriage return characters will be deleted, and new line characters will be changed to to the HTML tag <br>.

Examples:

<form action="/cgi-bin/baserun.exe" method="POST">
<input type="hidden" name="_ses" value="{session}">
<input type="hidden" name="_act" value="entry">
Character field:<input type="text" name="chr_field" size="20">

Character field 2:
<select name="chr_field2" size="1">
  <option value="Value 1">First choice</option>
  <option value="Value 2">Second choice</option>
  <option value="Value 3">Third choice</option>
</select>
Memo field:<textarea name="mem_field" rows="5" cols="20">
Date field:<input type="text" name="dat_field" size="20" value="{dtoc(date()}">
Logic field:<input type="checkbox" name="log_field" value="T">

<input type="submit" value="Submit"><input type="reset" value="Reset">

This form creates a new record, appended to the end of the database. The names of the entry fields in this form and the names of the fields in the database are the same. In this instance, the form uses the POST method. Because it collects data for a memo field, it is possible that the amount of data will be too much for the GET method to handle. This form uses a checkbox to determine the value of the logical field. If the user checks the box, the field will be set to true; otherwise the field will be set to false. The date field contains a default value of today's date, formatted according to the _dateformat variable.

<form action="/cgi-bin/baserun.exe" method="POST">
<input type="hidden" name="_ses" value="{session}">
<input type="hidden" name="_act" value="edit">
<p>Character field:

<input type="text" name="chr_field" size="20" value="{trim(chr_field)}">
<p>
Character field 2:
<select name="chr_field2" size="1">
  <option value="{trim(chr_field2)}">{trim(chr_field2)}</option>
  <option value="Value 1">Value 1</option>
  <option value="Value 2">Value 2</option>
  <option value="Value 3">Value 3</option>
</select>
Memo field:<textarea name="mem_field" rows="5" cols="20" value="{mem_field}">
Date field:<input type="text" name="dat_field" size="20" value="{dtoc(dat_field)}">

<input type="radio" value="T" {iif(log_field=.T.,'checked','        ')} name="log_field"> Yes
<input type="radio" value="F" {iif(.NOT.log_field,'checked','        ')} name="log_field"> No
<input type="submit" value="Submit"><input type="reset" value="Reset">

This form edits the same data. The differences are simply that this form supplies the values of the current fields in the form (in the case of the logical field, through radio buttons), and because it uses the edit action, it writes the edited data to the current record. The menu for chr_field2 is set up to place the current value of chr_field2 as the first option. This could also be accomplished with:

Character field 2:
<select name="chr_field2" size="1">
  <option value="{trim(chr_field2)}">{trim(chr_field2)}</option>
  <option value="Value 1" {iif(trim(chr_field2)='Value 1','SELECTED','         ')}>
  Value 1</option>
  <option value="Value 2" {iif(trim(chr_field2)='Value 2','SELECTED','         ')}>
  Value 2</option>
  <option value="Value 3" {iif(trim(chr_field2)='Value 3','SELECTED','         ')}>
  Value 3</option>
</select>

 


Copyright © 1998-99 baserunner Software (Mark Glover)