Linux.com

writing cgi using C++

Link to this post 24 May 11

Great!

Well, do you "believe" that data is passed through stdin, or you're exactly 100% certain?

And also, Rubberman, would you please tell me how to capture it?

Thanks

Link to this post 25 May 11

According to Wikipedia, Rubberman is right: POST uses stdin to pass data to your CGI program. In C++, you should then be able to use the cin-stream to capture the data.

Link to this post 28 May 11

Thanks jabirali,

Considering the fact that I've first explored the net and then picked the pen to weave a thread in forum, I already know that, and I've already used the most common methods of receiving data from cin, such as << and get(), but I know that here's something I don't know, say another member function of cin or something like that, that I don't know and is the key for me to going ahead.

Most of the resources on the net are writing perl programs as CGI and rarely I can find some "useful" page on net to have talked about writing CGI using C++ and thus discussing the most common problems.

I'll keep searching and trying other resources.

But thanks anyway ;-)

Link to this post 28 May 11

Have you tried doing something like this?


#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main()
{
stringstream ss;
ss << cin.rdbuf();

cout << "Content-type: text/html\\n\\n<html><body>\\n"
<< "Data received:\\n" << ss.str() << "\\n</body></html>\\n";

return 0;
}

Link to this post 28 May 11

Hell! it works! Thanks Jabir. ;-)

Link to this post 28 May 11

I'm glad I could help :)

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board