home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 8
/
amigaformatcd08.iso
/
in_the_mag
/
html_tutorial
/
mas_form.cpp
< prev
next >
Wrap
Text File
|
1996-09-03
|
2KB
|
102 lines
// (C) M.A.Smith University of Brighton
//
// Permission is granted to use this code
// provided this declaration and copyright notice remains intact.
//
// 26 August 1995
#include "t99_type.h"
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
void intro();
void finish();
void form_data_output();
void stream_data();
void return_button();
char* getenv_n( char [] );
// Main program
//
int main()
{
intro();
form_data_output();
stream_data();
return_button();
finish();
return 0;
}
void intro()
{
cout << "Content-type: text/html" << "\n"
<< "\n" << "\n" ;
cout << "<HTML> " << "\n";
cout << "<HEAD> " << "\n";
cout << "</HEAD> " << "\n";
cout << "<BODY> " << "\n";
}
void form_data_output( )
{
cout << "<P>" << "\n";
cout << "The data sent to the form processing program " <<
"in the environment variable QUERY_STRING is:" << "\n";
cout << "<P>" << "\n" << "\n";
cout << "<TABLE BORDER CELLPADDING=2>" << "\n";
cout << "<TD>" << "\n";
cout << getenv_n( "QUERY_STRING" ) << "\n";
cout << "</TD>" << "\n";
cout << "</TABLE>" << "\n";
}
void stream_data()
{
char ch;
cout << "<P>" << "\n";
cout << "Contents of stdin" << "<P>" << "\n";
cout << "<TABLE BORDER CELLPADDING=2>" << "\n";
cout << "<TD>" << "\n";
cout << "<PRE>" << "\n";
cout << "" << "\n";
{
int len = 0;
char *p_ch = getenv( "CONTENT_LENGTH" );
if ( p_ch != NULL ) len = atoi( p_ch );
if ( len > 0 )
{
cin >> resetiosflags( ios::skipws );
while ( cin >> ch, !cin.eof() )
{
cout << ch;
if ( --len <=0 ) break;
}
}
}
cout << "</PRE>" << "\n";
cout << "</TD>" << "\n";
cout << "</TABLE>" << "\n";
}
void return_button()
{
cout << "<P>" << "\n";
cout << "<TABLE BORDER CELLPADDING=2>" << "\n";
cout << "<TD>" << "\n";
cout << "<A HREF=\"" << getenv_n( "HTTP_REFERER" ) << "\" >" <<
"Return" << "</A>" << "\n";
cout << "</TD>" << "\n";
cout << "</TABLE>" << "\n";
}
void finish()
{
cout << "</BODY>" << "\n";
cout << "</HTML>" << "\n";
}