Solved

c++, cgi and HTML forms..

Posted on 2001-07-24
2
216 Views
Last Modified: 2013-12-25
Can anyone help me with html forms and c++ trough CGI..

I don't know how to retrive data I entered in the form..
Here is a short example on how do I get the data(I'm not sure if I'm doing it right)..

-------------------------------------------------------
#include <iostream.h>
void main()
{
int age;
char name;
cout << "Content-Type: text/html\r\n\r\n" << endl;
cout << "
   <HTML>
    <HEAD>
     <TITLE> TEST PAGE! </TITLE>
     </HEAD>
      <BODY>
       <form action=\"/cgi-bin/test2\" method=POST>
        Enter your name: <input type=text name=\"name\"><p>
        <input type=submit>
       </form>
      </BODY>
    </HTML>  " << endl;
return 0;
}
-------------------------------------------------------

I now want to create file named test2, that shows the data I have entered..

I was looking at c++/cgi tutorials but it seems everyone are using there own rutines on how to retrive
inputed data..
I would much apreciate if you would give me a short example..
THANK YOU!
0
Comment
Question by:jurij
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 6319333
char *str = (char *)NULL;
errno=0;
if (getenv("CONTENT_LENGTH")>0 && errno==0) {
   str = getenv('QUERY_STRING");
   if (str!=(char *)NULL && errno==0) {
      // now you need to split str into name-value pairs, for example using strtok
   }
}
0
 

Author Comment

by:jurij
ID: 6329481
char *str = (char *)NULL;
errno=0;
if (getenv("CONTENT_LENGTH")>0 && errno==0) {
  str = getenv('QUERY_STRING");
  if (str!=(char *)NULL && errno==0) {
     // now you need to split str into name-value pairs, for example using strtok
  }
}
--------------------------------------------------------

If I output, I get "REQUEST_URL=/cgi-bin/name"
What am I doing wrong?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question