CGI and Perl

Setting Up Your Search Pages

Take a closer look now at the browse and descsrch pages. They are a bit more interesting because they interact with your product database. These pages actually contain HTML forms, as shown in Listing 13.2, so they have some additional MiniVend tags to accommodate these forms.

Listing 13.2. The search page.

 <TITLE>Search the Web Shopping Network</TITLE>
 Search our Product Catalog
 <FORM ACTION="[process-search]" METHOD=POST>
 <STRONG>Product Keywords</STRONG><BR>
 <INPUT TYPE=text NAME="mv_searchspec" SIZE=20>
    <INPUT TYPE="submit" NAME="mv_todo" VALUE="Search">
    <INPUT TYPE="hidden" NAME="mv_doit" VALUE="search">
    <INPUT TYPE="hidden" NAME="mv_search_page" VALUE="results">
    Matches per page:
    <SELECT NAME="mv_matchlimit">
    <INPUT TYPE="radio" NAME="mv_orsearch" VALUE="no" CHECKED>Match all<BR>
    <INPUT TYPE="radio" NAME="mv_orsearch" VALUE="yes">Match any<BR>
    <INPUT TYPE="checkbox" NAME="mv_case" VALUE="yes">Case sensitive<BR>

This page contains some interesting MiniVend tags that you should be aware of. The first you come across is [process-search], which defines the post action for the form. It tells MiniVend to perform a database search using the criteria entered by the user. The rest of the MiniVend tags support the search program with the appropriate criteria. mv_searchspec specifies the text for which to search. mv_matchlimit specifies the maximum number of matches to allow being returned. mv_orsearch enables the user to specify searches that match all words entered or one or more of the words entered. mv_case enables the user to specify case-sensitive searches. In addition to these tags are several other field types that support searching, as you can see in the resulting form shown in Figure 13.2. For more information on these field types, refer to the MiniVend documentation, which is included with the MiniVend package.

Figure 13.2. The description search page.

The next page to look at is the browse page. The code for it is shown in Listing 13.3. This page is similar to the descsrch page except that it gives the user some categories from which to choose. Many of the MiniVend tags may look familiar to you after seeing the search page.

by BrainBellupdated