?? day6_2.html
字號:
<html>
<!-- #BeginTemplate "/Templates/backend.dwt" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a:link { color: blue; text-decoration: none}
a:visited { color: purple; text-decoration: none}
a:hover { color: #CC0033; text-decoration: underline}
.smallfont { font-family: "宋體"; font-size: 9pt; line-height: 12pt}
-->
</style>
<!-- #BeginEditable "doctitle" -->
<title>CGI入門教程</title>
<!-- #EndEditable -->
</head>
<body topmargin="1" leftmargin="2">
<p><!-- #BeginEditable "content" --> </p>
<p><span class="smallfont"><b>CGI入門教程</b><br>
<font color="#FF0000">第一頁</font> <a href="day6_1.html">設置口令</a><br>
<font color="#FF0000">第二頁</font> 計數器</span></p>
<p><span class="smallfont">[<a href="day1_1.html">第1天</a>][<a href="day2_1.html">第2天</a>][<a
href="day3_1.html">第3天</a>][<a href="day4_1.html">第4天</a>][<a href="day5_1.html">第5天</a>][第6天][<a
href="../perl.htm">返回</a>]</span></p>
<p><span class="smallfont"><b>第二頁:計數器</b></span></p>
<p><span class="smallfont">下面是一個簡單的計數器程序:</span></p>
<p><span class="smallfont">#******** BEGIN BODY ******** <br>
open (GETCOUNT,"<count.log");
#open count log for input <br>
$counter=<GETCOUNT>;
#assign contents of file to $counter <br>
close (GETCOUNT);
#close access to file </span></p>
<p><span class="smallfont">$counter++;
#increase $counter by 1. <br>
print "$counter hits";
#print number of hits to users screen </span></p>
<p><span class="smallfont">open (PUTCOUNT,">count.log");
#open count log for output <br>
print PUTCOUNT ($counter);
#replace old counter value with new one <br>
close PUTCOUNT;
# close access to file </span></p>
<p><span class="smallfont">#******** END BODY ********* </span></p>
<p><span class="smallfont">如果用SUBMIT按鈕,當前頁將消失,出現程序的輸出頁。為了在當前頁上顯示點擊數,需要有一個頁面轉載時執行的程序,然后把結果潛入相同頁面上。這種方法叫做Server
Side Include(SSI)。</span></p>
<p><span class="smallfont">注意:不是所有的web服務器都支持SSI。有些只在頁面文件以".shtml"或".html-ssi"結束才起作用,有些由于安全原因完全屏蔽了這種功能。</span></p>
<p><span class="smallfont">下面是代碼的工作過程:</span>
<ul>
<li><span class="smallfont">把上面的代碼拷貝到一個新的'template.txt'文件中,命名為count.cgi。</span></li>
<li><span class="smallfont">建立一個包含起始點擊數的文件,命名為count.log。</span></li>
<li><span class="smallfont">新建一個HTML頁面。</span></li>
<li><span class="smallfont">插入<!--#exec cgi="count.cgi"-->。</span></li>
<li><span class="smallfont">把上面3個文件上傳到服務器上。</span></li>
<li><span class="smallfont">Telnet到perltour文件夾中,敲入chmod a+rx count.cgi。</span></li>
<li><span class="smallfont">瀏覽這個頁面,重載幾次,可以看到數字的增加。</span></li>
</ul>
<p><span class="smallfont">如果不起作用,直接瀏覽count.cgi看它是否工作。一旦CGI起作用,把頁面文件重命名為.shtml擴展名。</span></p>
</body>
<!-- #EndTemplate -->
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -