Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4079838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:51:11+00:00 2026-05-20T17:51:11+00:00

I am new to CGI. I use Apache v2.2 and GNU cgicc v3.2.9. I

  • 0

I am new to CGI. I use Apache v2.2 and GNU cgicc v3.2.9. I want to use CGI for generating a HTML web page with a simple form. Aim of this work is to let an user send data by hiting a button on this CGI directly back to the "same" CGI. The CGI evaluates the data and changes the web page:

CGI –> CGI –> CGI –> …

I can not use a simple HTML page and sending the requests to a cgi because after that I have created a CGI page were the user can send again a request to this cgi which leads to the same situatiuon as introduced:

HTML –> CGI –> CGI –> CGI –> …

Using form method POST leads into a server error message while GET works:

access.log

[16/Mar/2011:15:00:50] "GET
/cgi-bin/cgiHandleEvents.cgi HTTP/1.1"
200 973

[16/Mar/2011:15:00:52] "GET
/cgi-bin/cgiHandleEvents.cgi?value1=&value2=option1&value3=button1&value4=data4
HTTP/1.1" 200 973

[16/Mar/2011:15:01:34] "GET
/cgi-bin/cgiHandleEvents.cgi HTTP/1.1"
200 974

[16/Mar/2011:15:01:37]
"POST /cgi-bin/cgiHandleEvents.cgi
HTTP/1.1" 500 538

error.log (I reduced the http:// to http// because of spam warning regarding my stackoverflow reputation)

[Wed Mar 16 15:01:37 2011] [error]
[client 127.0.0.1] Premature end of
script headers: cgiHandleEvents.cgi,
referer:
http//localhost/cgi-bin/cgiHandleEvents.cgi

[Wed Mar 16 15:01:37 2011] [error]
[client 127.0.0.1] \r, referer:
http//localhost/cgi-bin/cgiHandleEvents.cgi

[Wed Mar 16 15:01:37 2011] [error]
[client 127.0.0.1] This application
has requested the Runtime to terminate
it in an unusual way., referer:
http//localhost/cgi-bin/cgiHandleEvents.cgi

[Wed Mar 16 15:01:37 2011] [error]
[client 127.0.0.1] Please contact the
application’s support team for more
information.\r, referer:
http//localhost/cgi-bin/cgiHandleEvents.cgi

[Wed Mar 16 15:01:37 2011] [error]
[client 127.0.0.1] terminate called
after throwing an instance of
‘std::runtime_error’\r, referer:
http//localhost/cgi-bin/cgiHandleEvents.cgi

[Wed Mar 16 15:01:37 2011] [error]
[client 127.0.0.1] what(): I/O
error\r, referer:
http//localhost/cgi-bin/cgiHandleEvents.cgi

The current code contains no message handler. In my opinion on POST the page should simply reload. For checking the code you can exchange the lines containing the different form method.

#include "cgicc/CgiDefs.h"
#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"

using namespace std;
using namespace cgicc;

int main()
{
   Cgicc formData;
   Cgicc cgi;

   cout<< HTTPHTMLHeader() << endl;
   cout<< HTMLDoctype(HTMLDoctype::eStrict) << endl;
   cout<< html().set("lang", "EN").set("dir", "LTR") << endl;

   // Set up the HTML document
   cout<< html() << head() << title("Cgicc example") << head() << endl;
   cout<< body().set("bgcolor","#cccccc").set("text","#000000").set("link","#0000ff").set("vlink","#000080") << endl;

   try
   {
       cout<< h2("Test CGIcc form") << endl;
       cout<< "GNU cgicc v" << cgi.getVersion() << "<BR>" << endl;

       //cout<< "<form method=\"post\" action=\"cgiHandleEvents.cgi\">"<< endl;
       cout<< "<form method=\"get\" action=\"cgiHandleEvents.cgi\">"<< endl;

       cout<< "    Value 1:" << endl;
       cout<< "    <input type=\"text\" name=\"value1\">" << endl;
       cout<< "    <p></p>" << endl;
       cout<< "    Value 2:" << endl;
       cout<< "    <select name=\"value2\">" << endl;
       cout<< "        <option value=\"option1\">Option 1" << endl;
       cout<< "        <option value=\"option2\">Option 2" << endl;
       cout<< "        <option value=\"option3\">Option 3" << endl;
       cout<< "    </select>" << endl;
       cout<< "    <p></p>" << endl;
       cout<< "    Value 3:" << endl;
       cout<< "    <input type=\"radio\" name=\"value3\" value=\"button1\" checked=\"checked\">Button1" << endl;
       cout<< "    <input type=\"radio\" name=\"value3\" value=\"button2\">Button2" << endl;
       cout<< "    <input type=\"hidden\" name=\"value4\" value=\"data4\">" << endl;
       cout<< "    <p></p>" << endl;
       cout<< "    <input type=\"submit\" value=\"Submit\">" << endl;
       cout<< "</form>" << endl;
   }
   catch(exception& e)
   {
       // handle any errors here.
       cout<< h2("ERROR!!!") << endl;
   }
   // Close the HTML document
   cout << body() << html();
   return 0;   // To avoid Apache errors.
}

Does anybody have an idea what the problem is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:51:11+00:00Added an answer on May 20, 2026 at 5:51 pm

    I found the errors. First error is malformed HTML. Look out for opening and closing tag for html not enclosing the complete html page!

    cout<< html().set("lang", "EN").set("dir", "LTR") << endl;
    // Set up the HTML document
    cout<< html() << head() << title("Cgicc example") << head() << endl;
    

    Second error seems to be

    Cgicc formData;
    

    I do not know why this leads to an error. But If I do not use it the POST request works fine. If I think twice it makes no sense to have 2 instances of Cgicc. This is my fault. m(

    But I think this is a bug inside cgicc. I will file a bug on savanna…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to Regex. I want to validate to this format: Any character allowed, except
I tried to use this very simple script for uploading a file to my
I am starting a new c++ project and I want to use Boost.Build /
This is my code #!/usr/bin/perl -T use CGI; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard);
I'm a bit new to eclipse and want to use the following libraries so
# Object initialization: use CGI::Session; $session = CGI::Session->new(); $CGISESSID = $session->id(); # Send proper
new on ruby and using windows xp and rails 3, i want to send
New to PHP and MySQL, have heard amazing things about this website from Leo
new to c#. I'm trying to make a simple system where I can search
New programmer here, I am trying to understand and break down this code below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.