📄 formexample.html
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><html> <head> <title>GCGI Test</title> </head> <body> <h1>GCGI Test</h1> <form method=POST action="http://topeka.shingletowngap.org/cgi-bin/gcgiFormTest"> <p>Insert a Text String: <input name="string" type=text width=25 maxlength=127></p> <p>Insert a Text String (no new lines): <input name="nonewlines" type=text width=25 maxlength=127></p> <p>Insert an Integer: <input name="integer" type=text width=25></p> <p>Insert a Float: <input name="double" type=text width=25></p> <p>Single Checkbox: <input type=checkbox name=choice> </p> <p>Multiple Checkbox: Phish: <input type=checkbox name=band value="phish"> Widespread Panic: <input type=checkbox name=band value="wsp"> Moe.: <input type=checkbox name=band value="moe."> </p> <p>Insert Multiple Strings: <input name="mulstr" type=text width=25> <input name="mulstr" type=text width=25> <input name="mulstr" type=text width=25> <input name="mulstr" type=text width=25> <input name="mulstr" type=text width=25> </p> <p>Radio Buttons: <input type=radio name=radio value="red"> <input type=radio name=radio value="green"> <input type=radio name=radio value="blue"> </p> <p>TextArea (newlines):<br> <textarea name="tf1" cols=25 rows=5></textarea> </p> <p>TextArea (no newlines):<br> <textarea name="tf2" cols=25 rows=5></textarea> </p> <p>Single Select: <select name="singleselect"> <option>Red Hat</option> <option>SuSE</option> <option>Debian</option> </select> </p> <p>Multiple Select: <select name="multipleselect" multiple> <option>Lager</option> <option>Stout</option> <option>Pilsner</option> </select> </p> <input type=submit> </form> <p> Here is the code to make this happen: <pre>#include <stdlib.h>#include <stdio.h>#include "gcgi.h"int main (int argc, char *argv[], char *envp[]) { char tstring[128], qstring[128], *qs, **bands, tf1[256], tf2[256], mulstr[128]; int i, j, k, l, m, *n, o; double d; char *morebands[] = {"phish", "wsp", "moe." }; char *colors[] = {"red", "green", "blue" }; if (initCgi() < 0) return -1; gcgiNumFormFields(&k); gcgiNumFields("band",&l); gcgiFetchString("string", tstring, 128); gcgiFetchStringNoNewLines("nonewlines", qstring, 128); gcgiFetchInteger("integer", &i, -1); gcgiFetchDouble("double", &d, -1.0); gcgiFetchCheckbox("choice", &j); gcgiFetchMultipleString("band", &bands); n = XMALLOC(int, 3); gcgiFetchMultipleCheckbox("band", morebands, 3, &n); gcgiFetchSelectIndex("radio", colors, 3, &o, -1); gcgiFetchString("tf1", tf1, 255); gcgiFetchStringNoNewLines("tf2", tf2, 255); qs = gcgiFetchEnvVar(gcgiQueryString); fprintf(gcgiOut,"Content-Type: Text/HTML\n\n"); fprintf(gcgiOut, "<html>\n" "<head>\n" " <title>GCGI Test Results</title>\n" "</head>\n\n" "<body>\n" " <p><b>Total number of form fields:</b> %d</p>\n" " <p><b>Text String:</b> %s</p>\n" " <p><b>Text String (no new lines):</b> %s</p>\n" " <p><b>Integer:</b> %d</p>\n" " <p><b>Double:</b> %f</p>\n" " <p><b>Single Checkbox:</b> %s</p>\n" " <p><b>Number of checkboxes for \"band\":</b> %d\n" " <p><b>Bands:</b><ol>\n", k, tstring, qstring, i, d, j? "checked":"unchecked", l); if (bands != NULL) for (m = 0; bands[m] != NULL; m++) { fprintf(gcgiOut,"<li>%s</li>\n",bands[m]); } fprintf(gcgiOut, "</ol></p>\n" "<p><b>Radio Button Selected Index:</b> %d" "<p><b>Bands that were checked:</b><ol> ",o); for (m = 0; m < 3; m++) fprintf(gcgiOut,"<li><b>%s:</b> %s</li>",morebands[m], n[m]? "checked":"unchecked"); fprintf(gcgiOut,"</ol>\n<p><b>Fetch Multiple Strings one at a time:</b>\n<ol>\n"); while (gcgiFetchStringNext("mulstr", mulstr, 127) != GCGIFIELDNOTFOUND) fprintf(gcgiOut,"<li>%s</li>", mulstr); fprintf(gcgiOut, "</ol>\n<p><b>Text Field One:</b><br><pre>%s</pre><br>\n" "<p><b>Text Field Two (No Newlines):</b><br><pre>%s</pre><br>\n", tf1, tf2); fprintf(gcgiOut, "</p>\n" "<pre>\n" "QUERY_STRING: %s\n", qs); printQuery(gcgiOut); fprintf(gcgiOut, "</pre>\n" "</body>\n" "</html>\n"); gcgiFreeMultipleString(bands); XFREE(n); freeCgi(); return 0;} </pre> </p> <hr> <address><a href="mailto:catchen@topeka.rebelalliance.org">Julian M Catchen</a></address><!-- Created: Tue Jul 31 18:39:05 MST 2001 --><!-- hhmts start -->Last modified: Sat Jan 26 11:08:38 MST 2002<!-- hhmts end --> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -