<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Pronblem mit cgi]]></title><description><![CDATA[<p>Wenn ich zu erst eine post und dann eine Get anfrage stelle geht alles, wenn ich dies umgekehrt mache aber nicht, habe schon alles mögliche versucht bekomme es aber nicht in den griff:</p>
<p>cgi.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; 
#include &lt;string&gt; 
#include &lt;fstream&gt; 
#include &quot;include/libhtml++.h&quot; 

using namespace std; 

bool cgi::anfrage() 
 { 
     query = string(); // Gespeicherten Wert zurücksetzen 

     char *request = getenv(&quot;REQUEST_METHOD&quot;);
     char *env = getenv(&quot;QUERY_STRING&quot;);
     char *clength = getenv (&quot;CONTENT_LENGTH&quot;);

     if( request == 0 ) 
     { 
         return false; // Änderung des Rückgabewerts 
     } 

	if(request == std::string(&quot;GET&quot;)) 
	{ 
         if (env != 0) 
         { 
             query = env; 
             return true;   // Rückgabewert geändert 
         } 
         else 
         { 
             return false; // Rückgabewert geändert 
         } 
	}

	if(request == std::string(&quot;POST&quot;))
	{

	 if (clength != 0)
	{
	 	getline(cin, query);
	 	return true;
	}

		else
		return false;

	}

	else 
	return false;
 } 

bool cgi::output(const string&amp; formname) 
{ 

if (anfrage()) 
{ 

f_start = query.find(formname);
if ( f_start != string::npos)
{

v_start = query.find(&quot;=&quot;, f_start); 
v_start += 1; 
end = query.find(&quot;&amp;&quot;, v_start);

     if (end != string::npos)
         end -= 1; 
     if (end == string::npos)
         end = query.length();

size = end - v_start;
queryout = query.substr(v_start, size);
return true;

}
else 
{
return false;
}

}

else 
return false; 
};
</code></pre>
<p>htmlform.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &quot;include/libhtml++.h&quot;

using namespace std;

void htmlform::starthtml(string sitename)
{
cout &lt;&lt; &quot;Content-Type:text/html\n\n&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;html&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;head&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;title&gt;&quot; &lt;&lt; sitename &lt;&lt; &quot;&lt;/title&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;/head&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;body&gt;&quot; &lt;&lt; endl;
}

void htmlform::endhtml()
{
cout	&lt;&lt; &quot;&lt;/body&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;/html&gt;&quot;&lt;&lt; endl;
}

void htmlform::startform(string methodform)
{
cout &lt;&lt; &quot;&lt;form action=\&quot;index.cgi\&quot; method=&quot; &lt;&lt; methodform &lt;&lt; &quot;&gt;&quot; &lt;&lt; endl;
}

void htmlform::endform()
{
cout &lt;&lt; &quot;&lt;/form&gt;&quot; &lt;&lt; endl;
}

void htmlform::formselect (string formselectname, string formselectinput)
{
cout &lt;&lt; &quot; &lt;select  name=\&quot; &quot; &lt;&lt; formselectname &lt;&lt; &quot;\&quot;  &gt;&quot; &lt;&lt; formselectinput &lt;&lt; &quot;&gt; &lt;/select&gt;&quot; &lt;&lt; endl;
}

void htmlform::inputsubmit (string submitlabel)
{
cout &lt;&lt; &quot;&lt;input Type=\&quot;submit\&quot; value=\&quot;&quot; &lt;&lt; submitlabel &lt;&lt; &quot;\&quot; &gt;&quot; &lt;&lt; &quot;&lt;/input&gt;&quot; &lt;&lt; endl;
</code></pre>
<p>libhtml.h</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;

using namespace std; 

class cgi 
{
private:

int f_start;
int v_start;
int end;
int size;

public: 
string query;
string queryout;
bool anfrage(); 
bool output(const string&amp; formname);
};

class htmlform
{
private:

public:
void starthtml(string sitename);
void endhtml();
void startform(string methodform);
void endform();
void inputsubmit( string submitlabel);
void formselect(string formselectname, string formselectinput);
};

class htmllayer
{
private:

public:
void createlayer(string layerid);
void endlayer();
};
</code></pre>
<p>gesamte Anwendung <a href="http://rs204cg.rapidshare.com/files/62036788/tuxweblibs.tar.gz" rel="nofollow">http://rs204cg.rapidshare.com/files/62036788/tuxweblibs.tar.gz</a></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/194986/pronblem-mit-cgi</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 18:35:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/194986.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 12 Oct 2007 13:06:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pronblem mit cgi on Fri, 12 Oct 2007 13:10:38 GMT]]></title><description><![CDATA[<p>Wenn ich zu erst eine post und dann eine Get anfrage stelle geht alles, wenn ich dies umgekehrt mache aber nicht, habe schon alles mögliche versucht bekomme es aber nicht in den griff:</p>
<p>cgi.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; 
#include &lt;string&gt; 
#include &lt;fstream&gt; 
#include &quot;include/libhtml++.h&quot; 

using namespace std; 

bool cgi::anfrage() 
 { 
     query = string(); // Gespeicherten Wert zurücksetzen 

     char *request = getenv(&quot;REQUEST_METHOD&quot;);
     char *env = getenv(&quot;QUERY_STRING&quot;);
     char *clength = getenv (&quot;CONTENT_LENGTH&quot;);

     if( request == 0 ) 
     { 
         return false; // Änderung des Rückgabewerts 
     } 

	if(request == std::string(&quot;GET&quot;)) 
	{ 
         if (env != 0) 
         { 
             query = env; 
             return true;   // Rückgabewert geändert 
         } 
         else 
         { 
             return false; // Rückgabewert geändert 
         } 
	}

	if(request == std::string(&quot;POST&quot;))
	{

	 if (clength != 0)
	{
	 	getline(cin, query);
	 	return true;
	}

		else
		return false;

	}

	else 
	return false;
 } 

bool cgi::output(const string&amp; formname) 
{ 

if (anfrage()) 
{ 

f_start = query.find(formname);
if ( f_start != string::npos)
{

v_start = query.find(&quot;=&quot;, f_start); 
v_start += 1; 
end = query.find(&quot;&amp;&quot;, v_start);

     if (end != string::npos)
         end -= 1; 
     if (end == string::npos)
         end = query.length();

size = end - v_start;
queryout = query.substr(v_start, size);
return true;

}
else 
{
return false;
}

}

else 
return false; 
};
</code></pre>
<p>htmlform.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &quot;include/libhtml++.h&quot;

using namespace std;

void htmlform::starthtml(string sitename)
{
cout &lt;&lt; &quot;Content-Type:text/html\n\n&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;html&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;head&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;title&gt;&quot; &lt;&lt; sitename &lt;&lt; &quot;&lt;/title&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;/head&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;body&gt;&quot; &lt;&lt; endl;
}

void htmlform::endhtml()
{
cout	&lt;&lt; &quot;&lt;/body&gt;&quot; &lt;&lt; endl
	&lt;&lt; &quot;&lt;/html&gt;&quot;&lt;&lt; endl;
}

void htmlform::startform(string methodform)
{
cout &lt;&lt; &quot;&lt;form action=\&quot;index.cgi\&quot; method=&quot; &lt;&lt; methodform &lt;&lt; &quot;&gt;&quot; &lt;&lt; endl;
}

void htmlform::endform()
{
cout &lt;&lt; &quot;&lt;/form&gt;&quot; &lt;&lt; endl;
}

void htmlform::formselect (string formselectname, string formselectinput)
{
cout &lt;&lt; &quot; &lt;select  name=\&quot; &quot; &lt;&lt; formselectname &lt;&lt; &quot;\&quot;  &gt;&quot; &lt;&lt; formselectinput &lt;&lt; &quot;&gt; &lt;/select&gt;&quot; &lt;&lt; endl;
}

void htmlform::inputsubmit (string submitlabel)
{
cout &lt;&lt; &quot;&lt;input Type=\&quot;submit\&quot; value=\&quot;&quot; &lt;&lt; submitlabel &lt;&lt; &quot;\&quot; &gt;&quot; &lt;&lt; &quot;&lt;/input&gt;&quot; &lt;&lt; endl;
</code></pre>
<p>libhtml.h</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;

using namespace std; 

class cgi 
{
private:

int f_start;
int v_start;
int end;
int size;

public: 
string query;
string queryout;
bool anfrage(); 
bool output(const string&amp; formname);
};

class htmlform
{
private:

public:
void starthtml(string sitename);
void endhtml();
void startform(string methodform);
void endform();
void inputsubmit( string submitlabel);
void formselect(string formselectname, string formselectinput);
};

class htmllayer
{
private:

public:
void createlayer(string layerid);
void endlayer();
};
</code></pre>
<p>gesamte Anwendung <a href="http://rs204cg.rapidshare.com/files/62036788/tuxweblibs.tar.gz" rel="nofollow">http://rs204cg.rapidshare.com/files/62036788/tuxweblibs.tar.gz</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1383770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1383770</guid><dc:creator><![CDATA[Tuxist]]></dc:creator><pubDate>Fri, 12 Oct 2007 13:10:38 GMT</pubDate></item></channel></rss>