What exactly do you want to do?
Normally you use C++ CGI to handle form submissions.
The form is normally first send in HTML.
Do you have to do it in C++? PHP would be much easier.
If I understand your question correctly then the program will have to output every line of HTML code back to the server to be sent to the end user. I am not sure, but I believe a simple "cout" statement should do the trick.
Based on what I have done, which is for personal use, I noticed the the beginning, say down to the "<body>" tag was the same, so I created a file with the HTML code and did a simple read/output of this code. The same concept for the end of the HTML code that was the same.
For me the middle of the HTML code came from reading a file and processing the data into HTML code to create a table.
followed by some "javascript" to make some changes in the HTML code tat was displayed.
I am not sure of a better way to do this, so I would start with creating the HTML code for the page and then wrap the C++ code around the HTML code.
You may also want to start by sending the output to a file that you can use for testing. And later use the find and replace to change the file output to "std::cout" when it is working the way you want.
As a shortcut you could use #define OUT outFile Then when th program is working change "outFile" to "std::cout" and the compiler will make the replacement for you. This way as long as the "cout" statement is all the server needs it makes the program easy to work with.