Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于HTML表单输入的CGI未返回正确响应的问题_Html_C_Cgi - Fatal编程技术网

基于HTML表单输入的CGI未返回正确响应的问题

基于HTML表单输入的CGI未返回正确响应的问题,html,c,cgi,Html,C,Cgi,我正在尝试为我的网站编写一个简单的密码系统。没有用户名,没有类似的,只有一个密码,我可以分发给朋友。其思想是将一个值传递给下面用C编写的小型CGI程序: #include <stdio.h> #include <stdlib.h> int main(){ char *test; printf("Content-Type: text/html\n\n"); //give the content type test = getenv("QUERY_STR

我正在尝试为我的网站编写一个简单的密码系统。没有用户名,没有类似的,只有一个密码,我可以分发给朋友。其思想是将一个值传递给下面用C编写的小型CGI程序:

#include <stdio.h>
#include <stdlib.h>
int main(){
char *test;
printf("Content-Type: text/html\n\n");            //give the content type
test = getenv("QUERY_STRING");                    //get the data
//printf ("%s\n\n", test);                        //print it for debugging purposes
if (test == "test=test") {                        //check for correct password
    printf("<a href=\"home.html\">Enter.</a>");   //give the link if correct
}
else if (test == NULL){
    printf("Error.");
}
else{
    printf("Denied.", test);
}
return(0);
}
#包括
#包括
int main(){
字符*测试;
printf(“内容类型:text/html\n\n”);//给出内容类型
test=getenv(“查询字符串”);//获取数据
//printf(“%s\n\n”,test);//出于调试目的打印它
如果(test==“test=test”){//检查密码是否正确
printf(“”;//如果正确,请给出链接
}
else if(test==NULL){
printf(“错误”);
}
否则{
printf(“拒绝”,测试);
}
返回(0);
}
问题是,无论传递给它什么,它总是打印“拒绝”。每当我打印返回的数据时,它正是我所期望的,即“test=test”,但它仍然打印“Denied”。我很确定我做的是正确的,我想知道这是否是服务器(TinyWeb)的问题。HTML表单代码如下所示:

<form action="cgi-bin/cgi.exe" method="get">
    <input name="test" placeholder="Password">
    <input type="submit" value="enter">
</form>

在C中,不能使用
=
比较字符串。使用strcmp