Bài thực hành số 2: Tk Form đăng nhập, ảnh quảng cáo, số lượt đã truy cập
1. Yêu cầu: - Thiết kế Form đăng nhập (hình trái), cho phép lưu lại tài khoản. Nếu
đăng nhập thành công thì mở ra trang Home.asp (hình phải)
File Login.asp
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>User name</title>
</head>
<body>
<%
'Kiem tra neu da co Cookies thi dang nhap luon vao trang Home.asp
if request.cookies("Acc")("user")="Admin" and request.cookies("Acc")("pass")="12345" then
response.redirect("Home.asp")
else
'Neu chua co Cookies thi cho hien giao dien dang nhap
%>
GV: LÊ ANH TÚ - Bộ môn Mạng & Truyền thông – Khoa CNTT ĐH Thái Nguyên
Bài thực hành số 2: Tk Form đăng nhập, ảnh quảng cáo, số lượt đã truy cập
<form method="POST" action="login.asp">
<table border="1" width="56%" id="table1" bgcolor="#C0C0C0">
<tr>
<td width="129" height="35"><b>User name</b></td>
<td height="35">
<input name="txtUser" size="20"></td>
</tr>
<tr>
<td width="129" height="33"><b>Password</b></td>
<td height="33">
<input type="password" name="txtPass" size="19"></td>
end if
%>
</body>
</html>
File Home.asp
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Login successfull</title>
</head>
<body>
<p><b>Login successful !</b></p>
<form method="POST" action="Home.asp">
<p>Do you want <input type="submit" value="Logout" name="cmdLogout"></p>
</form>
<%
'Nhan Logout de huy Cookies
if request.form("cmdLogout")<>"" then
GV: LÊ ANH TÚ - Bộ môn Mạng & Truyền thông – Khoa CNTT ĐH Thái Nguyên
Bài thực hành số 2: Tk Form đăng nhập, ảnh quảng cáo, số lượt đã truy cập
response.cookies("Acc")("user")=""
response.cookies("Acc")("pass")=""
'Khong dung` Expires thi Cookies se bi huy
'ngay sau khi dong IE hien hanh`
response.redirect("Login1.asp")
end if
%>
</body>
</html>
GV: LÊ ANH TÚ - Bộ môn Mạng & Truyền thông – Khoa CNTT ĐH Thái Nguyên
Bài thực hành số 2: Tk Form đăng nhập, ảnh quảng cáo, số lượt đã truy cập
2. Thiết kế website như sau
Yêu cầu cho phép:
- Đếm số lượt người đã truy cập
- Hiển thị ảnh quảng cáo ngẫu nhiên
Yêu cầu: Sử dụng file Global.asa
(Ghi chú: Chuẩn bị sẵn 3 ảnh: 1.gif, 2.gif, 3.gif)
File Global.asa
<OBJECT ID="Dem" RUNAT="Server" SCOPE="Application"
PROGID="MSWC.Counters">
</OBJECT>
<OBJECT ID="Pic" RUNAT="Server" SCOPE="Application"
PROGID="MSWC.Adrotator">
</OBJECT>
File Quangcao.asp
<%
response.write "So luot ttruy cap website la:"
%>
<%
dem.Increment("k")
response.write dem.get("k")
%>
<br>
<%
=pic.GetAdvertisement("quangcao.txt")
‘noi dung file quangcao.txt nhu tren
%>
GV: LÊ ANH TÚ - Bộ môn Mạng & Truyền thông – Khoa CNTT ĐH Thái Nguyên
File Quangcao.txt