Simple CGI

My code works but with the html form sends the data to the c++ program it outputs input1= and then the value. How do i get it to output just the value?

header file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef WEBCGI_H
#define WEBCGI_H

#include <iostream>
#include <string>
#include <cstdlib>

using namespace std; 

class webcgi {
public:
	webcgi();
	void web_cout(string);
	void web_header();
	void web_footer();
	void web_trans(char*);
private:
	string input; 
};
webcgi::webcgi(){
}
void webcgi::web_cout(string mod) {
	printf(mod.c_str());
}
void webcgi::web_header() {
	printf("HTTP/1.0 200 OK\n");
    printf("Content-Type: text/html\n\n\n");
	printf("<html>");
	printf("<body>\n");

}
void webcgi::web_footer() {
	printf("</body>");
	printf("</html>");
}
void webcgi::web_trans(char *htmlin) {
	 printf("You entered: %s \n",htmlin);
}
#endif 


cpp file

1
2
3
4
5
6
7
8
9
10
#include "webcgi.h"

int main() {
	char *input;
	input = getenv("QUERY_STRING");
	webcgi control;
	control.web_header();
	control.web_trans(input);
	control.web_footer();
}


html file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form name="form1" action="cgi-bin/WebpageCGI.exe" method="get" />
<input name="input1" type="text" />

</form>
</body>
</html>
Last edited on
you can see what's happening here www.rjmlocal.com , surely this is something simple.
Topic archived. No new replies allowed.