// Cfour CgiParser example
// this standalone cgi program recursively calls itself
#define VAL( x ) Cgi.get_value( x )
#include "cgiparser.h"
int main() {
CgiParser Cgi; // create a CgiParser object
// write beginning html tags
Cgi << "<html>\n<head>\n<title></title>\n<body>\n\n";
// write dynamic data, if there is any
if(!Cgi.is_empty()) {
if(VAL("first_name") != BLANK) {
Cgi << "First Name: " << "first_name" << "<br>\n";
}
if(VAL("last_name") != BLANK) {
Cgi << "Last Name: " << "last_name" << "<br>\n";
}
// Note: BLANK is defined as "\0", used when vaule isn't found
// Also notice that Cgi << "first_name" doesn't actually print
// the string "first_name", it prints the value of the cgi
// variable "first_name".
// However, if you try to print a variable that doesn't exist,
// then it will print the string literal.
}
// static part of web form
string staticPage;
staticPage = "\
<form action=\"example.cgi\" method=\"POST\"><br><br>\n\
<input type=\"text\" name=\"first_name\"><br>\n\
<input type=\"text\" name=\"last_name\"><br>\n\
<input type=\"submit\" value=\"Submit\"> \
<input type=\"reset\" value=\"Reset\">\n\
</form><br>\n\
";
// write the form
Cgi << staticPage;
Cgi << "\n</body>\n</html>\n";
// write closing html tags
return 0;
}
| w | e | b | c | p | p |
|
| |||||