1.Apache的安装 地址:链接:https://pan.baidu.com/s/1kWdSWwZ 密码:nuqo
2.在相应路径下写html如图所示
new.html代码:
1 <html> 2 <body> 3 <form method="post" name=" = "test" action="cgi-bin/1.cgi"> 4 <input name="name" /> 5 <br /> 6 <input name= "password" /> 7 <input type="submit" value="post"> 8 </form> 9 </body> 10 </html>
3.cgi路径:
- cgi代码
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 5 void main() 6 { 7 printf("Content-type:text/html \n\n"); 8 char str[1024] = { 0 }; 9 gets(str); 10 printf("<br>"); 11 printf("您输入的是:%s", str); 12 }
运行效果:
点击post后: