?? day6_1.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><tt><span class="smallfont"><b>CGI入門教程</b><br>
<br>
<font color="#FF0000">第一頁</font> 設置口令<br>
<font color="#FF0000">第二頁</font> <a href="day6_2.html">計數器</a></span></tt></p>
<p><tt><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></tt></p>
<p><tt><span class="smallfont"> </span></tt></p>
<p><tt><span class="smallfont"><b>第一頁:設置口令</b></span></tt></p>
<p><tt><span class="smallfont">CGI的一個有趣的特征是即使任何用戶都能執行它們,但卻沒有辦法在屏幕上顯示她們。這意味著可以做一個口令腳本:</span></tt></p>
<p><span class="smallfont"><b><tt>#********BEGIN BODY**************</tt></b> </span></p>
<p><span class="smallfont"><b><tt>if ($value[0] ne "mypassword") {</tt></b> <br>
<b><tt> print "Invalid Password";</tt></b> <br>
<b><tt>} else {</tt></b> <br>
<b><tt>print '</tt></b> </span></p>
<p><span class="smallfont"><b><tt><BODY BGCOLOR="WHITE"></tt></b> </span></p>
<p><span class="smallfont"><b><tt><H1> Welcome, you have entered the<P></tt></b>
<br>
<b><tt>Password protected site </H1></tt></b> </span></p>
<p><span class="smallfont"><b><tt>';</tt></b> <br>
<b><tt>};</tt></b> </span></p>
<p><span class="smallfont"><b><tt>#*********END BODY***************</tt></b> </span></p>
<p><tt><span class="smallfont">要用這個腳本,需要建立一個有form的HTML頁面。如果在form上只有password一個box,則在運行腳本時它傳遞給$value[0]。</span></tt></p>
<p><tt><span class="smallfont">和JavaScript不同,用戶看不到源代碼,所以使用以下代碼是安全的:</span></tt></p>
<p><tt><span class="smallfont">if ($value[0] ne "mypassword") { </span></tt></p>
<p><tt><span class="smallfont">第一行為IF語句,與在JavaScript中的用法相似。</span></tt></p>
<p><tt><span class="smallfont">在Perl中,IF語句不同,取決于是比較數字還是文本。比較數字,可以用==,
!=, >, <符號。如果比較文本,用eq判斷是否相等,用ne判斷是否不相等。</p> </span></tt></p>
<p><tt><span class="smallfont">上面的語句確定在用戶輸入的文本不等于"mypassword"時將做什么。</span></tt></p>
<p><tt><span class="smallfont">print "Invalid Password";</span></tt></p>
<p><tt><span class="smallfont">口令不對時打印某些信息。</span></tt></p>
<p><tt><span class="smallfont">} else {</span></tt></p>
<p><tt><span class="smallfont">否則...</span></tt></p>
<p><span class="smallfont"><b><tt>print '</tt></b> </span></p>
<p><span class="smallfont"><b><tt><BODY BGCOLOR="WHITE"></tt></b> </span></p>
<p><span class="smallfont"><b><tt><H1> Welcome, you have entered the<P></tt></b>
<br>
<b><tt>Password protected site </H1></tt></b> </span></p>
<p><span class="smallfont"><b><tt>';</tt></b> </span></p>
<p><tt><span class="smallfont">口令正確,進入有口令保護的網站。<a
href="day6_2.html">>></a></span></tt></p>
</body>
<!-- #EndTemplate -->
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -