I am working on a simple message board written in C using CGI, but I keep getting an internal error. I have reviewed my code 100 times and still cant find it.
Can anybody spot the problem?Code:#include <stdio.h>
#include <stdlib.h>
void append(void)
{
FILE *log = fopen("log.txt","a");
char m[101];
char *qs = getenv("QUERY_STRING");
if(qs != NULL)
{
if(sscanf(qs,"m=%100s",m) == 1)
{
fputs(m,log);
}
}
fclose(log);
return;
}
void recreate(void)
{
FILE *log;
char m[101];
log = fopen("log.txt","r");
printf("Content-Type: text/html\n\n<html><head><title>Message Board</title></head><body>");
while(!feof(log))
{
fgets(m,sizeof m,log);
printf("%s</br>",m);
}
printf("<form action=\"http://98.243.228.110/cgi-bin/mb.cgi\" method=\"get\"><div><label><input name=\"m\"></label></div></form></body></html>");
fclose(log);
return;
}
int main(void)
{
append();
recreate();
return EXIT_SUCCESS;
}