"Fossies" - the Fresh Open Source Software Archive

Member "libgcgi.a-0.9.5/examples/formexample.html" (22 Jun 2002, 5186 Bytes) of package /linux/www/old/gcgi-0.9.5.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    2 <html>
    3   <head>
    4     <title>GCGI Test</title>
    5   </head>
    6 
    7   <body>
    8     <h1>GCGI Test</h1>
    9     <form method=POST action="http://topeka.shingletowngap.org/cgi-bin/gcgiFormTest">
   10       <p>Insert a Text String: <input name="string" type=text width=25 maxlength=127></p>
   11       <p>Insert a Text String (no new lines): <input name="nonewlines" type=text width=25 maxlength=127></p>
   12       <p>Insert an Integer: <input name="integer" type=text width=25></p>
   13       <p>Insert a Float: <input name="double" type=text width=25></p>
   14       <p>Single Checkbox:
   15     <input type=checkbox name=choice>
   16       </p>
   17       <p>Multiple Checkbox:
   18     Phish: <input type=checkbox name=band value="phish">
   19     Widespread Panic: <input type=checkbox name=band value="wsp">
   20     Moe.: <input type=checkbox name=band value="moe.">
   21       </p>
   22       <p>Insert Multiple Strings:
   23     <input name="mulstr" type=text width=25>
   24     <input name="mulstr" type=text width=25>
   25     <input name="mulstr" type=text width=25>
   26     <input name="mulstr" type=text width=25>
   27     <input name="mulstr" type=text width=25>
   28       </p>
   29       <p>Radio Buttons:
   30     <input type=radio name=radio value="red">
   31     <input type=radio name=radio value="green">
   32     <input type=radio name=radio value="blue">
   33       </p>
   34       <p>TextArea (newlines):<br>
   35     <textarea name="tf1" cols=25 rows=5></textarea>
   36       </p>
   37       <p>TextArea (no newlines):<br>
   38     <textarea name="tf2" cols=25 rows=5></textarea>
   39       </p>
   40       <p>Single Select:
   41     <select name="singleselect">
   42       <option>Red Hat</option>
   43       <option>SuSE</option>
   44       <option>Debian</option>
   45     </select>
   46       </p>
   47       <p>Multiple Select:
   48     <select name="multipleselect" multiple>
   49       <option>Lager</option>
   50       <option>Stout</option>
   51       <option>Pilsner</option>
   52     </select>
   53       </p>
   54       <input type=submit>
   55     </form>
   56     <p>
   57       Here is the code to make this happen:
   58 
   59       <pre>
   60 #include &lt;stdlib.h&gt;
   61 #include &lt;stdio.h&gt;
   62 #include "gcgi.h"
   63 
   64 int main (int argc, char *argv[], char *envp[]) {
   65 
   66   char tstring[128], qstring[128], *qs, **bands, tf1[256], tf2[256], mulstr[128];
   67   int i, j, k, l, m, *n, o;
   68   double d;
   69   char *morebands[] = {"phish", "wsp", "moe." };
   70   char *colors[]    = {"red", "green", "blue" };
   71 
   72   if (initCgi() &lt; 0)
   73     return -1;
   74 
   75   gcgiNumFormFields(&k);
   76   
   77   gcgiNumFields("band",&l);
   78 
   79   gcgiFetchString("string", tstring, 128);
   80 
   81   gcgiFetchStringNoNewLines("nonewlines", qstring, 128);
   82 
   83   gcgiFetchInteger("integer", &i, -1);
   84 
   85   gcgiFetchDouble("double", &d, -1.0);
   86 
   87   gcgiFetchCheckbox("choice", &j);
   88 
   89   gcgiFetchMultipleString("band", &bands);
   90 
   91   n = XMALLOC(int, 3);
   92 
   93   gcgiFetchMultipleCheckbox("band", morebands, 3, &n);
   94 
   95   gcgiFetchSelectIndex("radio", colors, 3, &o, -1);
   96 
   97   gcgiFetchString("tf1", tf1, 255);
   98 
   99   gcgiFetchStringNoNewLines("tf2", tf2, 255);
  100 
  101   qs = gcgiFetchEnvVar(gcgiQueryString);
  102 
  103   fprintf(gcgiOut,"Content-Type: Text/HTML\n\n");
  104 
  105   fprintf(gcgiOut,
  106       "&lt;html&gt;\n"
  107       "&lt;head&gt;\n"
  108       "    &lt;title&gt;GCGI Test Results&lt;/title&gt;\n"
  109       "&lt;/head&gt;\n\n"
  110       "&lt;body&gt;\n"
  111       "    &lt;p&gt;&lt;b&gt;Total number of form fields:&lt;/b&gt; %d&lt;/p&gt;\n"
  112       "    &lt;p&gt;&lt;b&gt;Text String:&lt;/b&gt;  %s&lt;/p&gt;\n"
  113       "    &lt;p&gt;&lt;b&gt;Text String (no new lines):&lt;/b&gt;  %s&lt;/p&gt;\n"
  114       "    &lt;p&gt;&lt;b&gt;Integer:&lt;/b&gt;      %d&lt;/p&gt;\n"
  115       "    &lt;p&gt;&lt;b&gt;Double:&lt;/b&gt;       %f&lt;/p&gt;\n"
  116       "    &lt;p&gt;&lt;b&gt;Single Checkbox:&lt;/b&gt; %s&lt;/p&gt;\n"
  117       "    &lt;p&gt;&lt;b&gt;Number of checkboxes for \"band\":&lt;/b&gt; %d\n"
  118       "    &lt;p&gt;&lt;b&gt;Bands:&lt;/b&gt;&lt;ol&gt;\n",
  119       k, tstring, qstring, i, d, j? "checked":"unchecked", l);
  120 
  121   if (bands != NULL)
  122     for (m = 0; bands[m] != NULL; m++) {
  123       fprintf(gcgiOut,"&lt;li&gt;%s&lt;/li&gt;\n",bands[m]);
  124     }
  125 
  126   fprintf(gcgiOut,
  127       "&lt;/ol&gt;&lt;/p&gt;\n"
  128       "&lt;p&gt;&lt;b&gt;Radio Button Selected Index:&lt;/b&gt; %d"
  129       "&lt;p&gt;&lt;b&gt;Bands that were checked:&lt;/b&gt;&lt;ol&gt; ",o);
  130 
  131   for (m = 0; m &lt; 3; m++)
  132     fprintf(gcgiOut,"&lt;li&gt;&lt;b&gt;%s:&lt;/b&gt; %s&lt;/li&gt;",morebands[m], n[m]? "checked":"unchecked");
  133 
  134   fprintf(gcgiOut,"&lt;/ol&gt;\n&lt;p&gt;&lt;b&gt;Fetch Multiple Strings one at a time:&lt;/b&gt;\n&lt;ol&gt;\n");
  135   while (gcgiFetchStringNext("mulstr", mulstr, 127) != GCGIFIELDNOTFOUND)
  136     fprintf(gcgiOut,"&lt;li&gt;%s&lt;/li&gt;", mulstr);
  137 
  138   fprintf(gcgiOut,
  139       "&lt;/ol&gt;\n&lt;p&gt;&lt;b&gt;Text Field One:&lt;/b&gt;&lt;br&gt;&lt;pre&gt;%s&lt;/pre&gt;&lt;br&gt;\n"
  140       "&lt;p&gt;&lt;b&gt;Text Field Two (No Newlines):&lt;/b&gt;&lt;br&gt;&lt;pre&gt;%s&lt;/pre&gt;&lt;br&gt;\n",
  141       tf1, tf2);
  142 
  143   fprintf(gcgiOut,
  144       "&lt;/p&gt;\n"
  145       "&lt;pre&gt;\n"
  146       "QUERY_STRING: %s\n",
  147       qs);
  148   printQuery(gcgiOut);
  149   fprintf(gcgiOut,
  150       "&lt;/pre&gt;\n"
  151       "&lt;/body&gt;\n"
  152       "&lt;/html&gt;\n");
  153   
  154   gcgiFreeMultipleString(bands);
  155   XFREE(n);
  156 
  157   freeCgi();
  158 
  159   return 0;
  160 }
  161       </pre>
  162     </p>
  163 
  164 
  165     <hr>
  166     <address><a href="mailto:catchen@topeka.rebelalliance.org">Julian M Catchen</a></address>
  167 <!-- Created: Tue Jul 31 18:39:05 MST 2001 -->
  168 <!-- hhmts start -->
  169 Last modified: Sat Jan 26 11:08:38 MST 2002
  170 <!-- hhmts end -->
  171   </body>
  172 </html>