Mar 24, 2012 at 3:39pm UTC
Hello guys!
This is my first forum participation experience, so please be nice!:)
I am working on a small program which is going to prioritize 20 sentences according to the degree of importance.
I want to do it via C++ via Web interface
right now'm trying to send <textarea> 20 sentences to some .cgi file to make it stored in some .txt file.
difficulty: cannot send anything via post, it says 0 bytes have been sent.
what do I do?
here's my script code:
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
#include <stdio.h>
#include <stdlib.h>
void main(void ) {
char *RemoteAddr = getenv("REMOTE_ADDR" );
char *ContentLength = getenv("CONTENT_LENGTH" );
char *QueryString = getenv("QUERY_STRING" );
int NumBytes = atoi(ContentLength);
char *Data = (char *)malloc(NumBytes + 1);
fread(Data, 1, NumBytes, stdin);
Data[NumBytes] = 0;
printf("Content-type: text/html\n\n" );
printf("<html><body>" );
printf("<h1>Yo guys, what's up!?</h1>" );
printf("ip address: %s<br>" ,RemoteAddr);
printf("Number of bytes: %d<br>" ,NumBytes);
printf("20 sentences: %s<br>" ,Data);
printf("check if at least URL thing working: %s" ,
QueryString);
printf("</body></html>" );
}
here's what I get as the output:
1 2 3 4 5
Yo guys, what's up!?
ip address: 127.0.0.1
Number of bytes: 0
20 sentences:
check if at least URL thing working: working_HARD!
I do type text into the form.. I wonder why there's no bytes? and no data has been sent?
Last edited on Mar 24, 2012 at 3:45pm UTC
Mar 24, 2012 at 3:46pm UTC
Well...what you wrote above is in C not in C++, as far as I know. On the other hand, I see in your code a combination of HTML and C, actually, something that I've never seen before. I didn't actually knew that can exist something like this.
Mar 24, 2012 at 3:57pm UTC
thank you for the reply CosminNTG!
yeah, I know:) not many people do that, I wanna try C/C++ in Web
i don't know, I go look some other forums may be
thanks again CosminNTG!
Mar 24, 2012 at 7:43pm UTC
But C or C++ are not suitable for web programming. Those are not web-programming languages, they aren't even scripting languages. Try to do it in Java or PHP, you'll definitely do it!
Last edited on Mar 24, 2012 at 7:43pm UTC