html中使用 c output,c - End of script outputs - CGI/HTML - Stack Overflow

We were asked to create a log-in page in HTML/CGI. I came up with this code:

#include

#include

#include

char username[20];

char password[20];

char* extract_value(char* data,int data_len, char* name, char* dest);

int main()

{

int size;

char *buff;

printf("Content-type:text/html\n\n");

printf("

");

buff = getenv("CONTENT_LENGTH");

if (buff)

size = atoi(buff);

char data[size+1];

int i;

for(i=0;i

data[i]=fgetc(stdin);

data[size]='\0';

extract_value(data,size+1,"username",username);

extract_value(data,size+1,"password",password);

printf("");

}

char* extract_value(char* data,int data_len, char* name, char* dest)

{

int i,j,k,flag,carry;

for(i=0;i

flag=1;

for(j=0,k=0;name[j]!='\0';j++,k++)

{

if(j>=data_len)

{

i=data_len;

break;

}

else if(name[j]!=data[i+k]){

flag=0;

break;

}

carry=i+k+2;

}

if(flag)

{

j=carry;

for(k=0;data[j]!='&'&&data[j]!='\0';j++,k++)

{

dest[k]=data[j];

}

dest[k]='\0';

break;

}

}

return dest;

}

And here's my HTML program:

Username:

Password:

After compiling it and running it through Apache/XAMPP, it comes up with this error:

Server error!

The server encountered an internal error and was unable to complete your request.

Error message:

End of script output before headers: 11.cgi

If you think this is a server error, please contact the webmaster.

Any idea how to fix this type of problem? Thanks a lot!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值