Professional Documents
Culture Documents
Bộ bài tập ASP cơ bản, gồm 50 bài, từng bước từng bước, tương đối dễ học. Mong các bạn sưu
tầm tiếp và cập nhật thêm, để bộ sưu tập này nhiều lên và hữu ích hơn.
---------------------------
Băng qua việc cài đặt trình IIS trong WINDOWS, tạo thư mục ViduASP và soạn thảo các bài tập
vào đó, Share thư mục ViduASP thành WEB bằng cách chọn WebSharing. Cuối cùng có thể
chạy bằng địa chỉ trên Address của IE là http://localhost/viduAsp/tenfile.asp
Next
%>
<%
31. Lấy thông tin từ máy chủ If Request.Form("txt")<>"" Then
Response.Write("You submitted: ")
<html> Response.Write(Request.Form)
<body> Response.Write("<br><br>")
Response.Write("Total bytes: ")
<p> Response.Write(Request.Totalbytes)
All possible server variables: End If
</p> %>
<%
For Each Item in Request.ServerVariables </body>
Response.Write(Item & "<br />") </html>
Next
%> 34. Kiểm tra xem 1 file nào đó bị thay
đổi lần cuối là khi nào?
</body>
</html> <html>
<body>
32. Kiểm tra xem bạn đăng nhập trang
web lần đầu tiên hay bao nhiêu? <%
<% Set fs =
dim numvisits Server.CreateObject("Scripting.FileSystemO
response.cookies("NumVisits").Expires=dat bject")
e+365 Set rs =
numvisits=request.cookies("NumVisits") fs.GetFile(Server.MapPath("demo_lastmodifi
ed.asp"))
if numvisits="" then modified = rs.DateLastModified
response.cookies("NumVisits")=1 %>
response.write("Welcome! This is the first This file was last modified on: <
time you are visiting this Web page.") %response.write(modified)
else Set rs = Nothing
response.cookies("NumVisits")=numvisits Set fs = Nothing
+1 %>
response.write("You have visited this ")
response.write("Web page " & numvisits) </body>
if numvisits=1 then </html>
response.write " time before!"
else
response.write " times before!" 35. Mở 1 file text để đọc nội dung
end if <html>
<body> 37. Kiểm tra xem 1 tên file nào đó kể
cả đường dẫn có tồn tại hay không?
<%
Set FS = <html>
Server.CreateObject("Scripting.FileSystemO <body>
bject")
Set RS = <%
FS.OpenTextFile(Server.MapPath("text") & Set
"\TextFile.txt",1) fs=Server.CreateObject("Scripting.FileSyste
While not rs.AtEndOfStream mObject")
Response.Write RS.ReadLine
Response.Write("<br />") If
Wend (fs.FileExists("c:\winnt\cursors\3dgarro.cur")
%> )=true Then
Response.Write("File
<p> c:\winnt\cursors\3dgarro.cur exists.")
<a href="text/textfile.txt"><img Else
border="0" Response.Write("File
src="/images/btn_view_text.gif"></a> c:\winnt\cursors\3dgarro.cur does not
</p> exist.")
End If
</body>
</html> set fs=nothing
%>
36. Kiểm tra xem 1 file nào đó được mở
ra bao nhiêu lần </body>
<% </html>
Set
FS=Server.CreateObject("Scripting.FileSyste 38. Kiểm tra xem 1 thư mục nào đó có
mObject") tồn tại thực sự hay không?
Set
RS=FS.OpenTextFile(Server.MapPath("count <html>
er.txt"), 1, False) <body>
fcount=RS.ReadLine <%
RS.Close Set
fs=Server.CreateObject("Scripting.FileSyste
fcount=fcount+1 mObject")
set fs=nothing
Set
fs=Server.CreateObject("Scripting.FileSyste Set f=Nothing
mObject") Set fs=Nothing
%>
Set
f=fs.OpenTextFile(Server.MapPath("testread 47. File được tạo ra lúc nào
.txt"), 1)
Response.Write(f.ReadLine) <html>
f.Close <body>
Set RS =
Server.CreateObject("ADODB.Recordset")
SQLStatement = "SELECT * FROM hoso
WHERE TenDangNhap='"& bTenDangNhap
&"' and MatKhau='"& bMatKhau &"'"
RS.Open SQLStatement, Conn, 3, 3
rs.MoveFirst
rs.Fields("TenDangNhap")=btenDangNhap
rs.Fields("hoten")=bhoten
rs.Fields("matkhau")=bmatkhau
rs.Fields("diachi")=bdiachi
rs.Fields("dienthoai")=bdienthoai
rs.Fields("email")=bemail
rs.Update
rs.Close
set rs=nothing
Response.Write "Ban da sua doi thong tin
trong profile thanh cong"
%>
</BODY>
</HTML>