Có 2 cách lấy dữ liệu:
- bằng phương thức post
- bằng phương thức get
a) Lấy dữ liệu bằng post
Tạo file post_in.asp có nội dung:
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="vi" />
<body>
<h4>Xin hãy cho biết tên và năm sinh</h4>
<form method="post" action="post_out.asp">
<input type="text" placeholder="Tên bạn là gì?" name="ten" /> <br />
<input type="text" placeholder="Bạn sinh năm nào?" name="namsinh" /> <br />
<input type="submit" value="OK" name="cmdOK" />
</form>
</body>
</html>
Tạo file post_out.asp có nội dung:
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="language" content="vi" /> <body> <% Dim ten Dim namsinh ten=request.form("ten") namsinh=request.form("namsinh") Dim tuoi tuoi=year(date)- namsinh
response.write("Xin chào bạn "& ten & ", hiện tại bạn đã " &tuoi&" tuổi")
%> </body> </html> |
https://tritue.edu.vn/tuecode/tracnghiem30/index.php/baiviet/post/view/id/194?id=194