📄 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 + -