CGI入门教程

第一页:回应脚本

这段脚本将显示输入到HTML FORM中的文本。它是一个信息如何传递给你的程序的简单的例子。既然你现在已经有了一个有着正确的Perl和Senmail的路径的template.txt文件,下面要做的只是编辑CGI的BODY部分。

  • 拷贝下面脚本的BODY部分到template.txt,然后保存到一个新文件"test2.cgi"中。
  • FTP test2.cgi到perltour文件夹(或cgi-bin)中。
  • 然后在Unix提示符下,进入perltour(或cgi-bin)文件夹,敲入chmod a+rx test2.cgi设置权限。
  • 现在可以在你的浏览器中打开服务器上的testform.htm,测试这个form。当你填充这个form并按"Test It"时,CGI告诉你你输入了什么。

 



#!/usr/local/bin/perl
#
&readparse;
print "Content-type: text/html\n\n";
#
#*****************BEGIN BODY*************

print "<h1>Thank you for filling out the form</h1>";

$firstname = $value[0];
$lastname = $value[1];
$email = $value[2];
 
print "Your first name is $firstname<BR>";
print "Your last name is $lastname<BR>";
print "Your e-mail is $email<BR>";
 
   
#***************END BODY******************

>>

CGI入门教程
第一页 回应脚本
第二页 脚本解释
第三页 BODY部分

[第1天][第2天][第3天][第4天][第5天][第6天]