


| Thực hành Insert dữ liệu vào bảng tblUser |
Thực hành Insert dữ liệu vào bảng tblUserChúng ta sẽ làm một ứng dụng nhỏ.
Thay vì Insert dữ liệu vào bảng tblUser trực tiếp từ MS Access, chúng ta sẽ làm việc đó từ web site. Ứng dụng của chúng ta bao gồm 3 trang.
Bạn vào đây tham khảo code của trang Connection.asp. Còn đây là nôi dung trang RegistrationForm.htm <html> <head> <title>Registration</title> </head> <body> <form method="POST" action="RegistrationProcess.asp"> <p> Username: <input type="text" name="username" ></p> <p> Password: <input type="password" name="password" ></p> <p> Confirm Password: <input type="password" name="ConfirmPassword" ></p> <p> Address: <input type="text" name="address"></p> <p><input type="submit" value="Submit" name="submit"></p> </form> </body> </html> Và trang RegistrationProcess.asp. Lưu ý phải có phần #include file... <!--#include file ="Connection.asp"--> <% username=request.form("username") password=request.form("password") confirmPassword=request.form("confirmPassword") address=request.form("address") ' validate some information retrieved from submitted form openConn sql="insert into tblUser([username],[password],[address]) values('"&username&"','"&password&"','"&address&"')" conn.execute sql destroyConn response.write "Successful Registration!" %> Bạn upload cả 3 trang lên Server. Sau đó chạy thử trang RegistrationForm.htm từ trình duyệt, ví dụ http://tenbanchon.co.cc/RegistrationForm.htm Bạn sẽ thấy tương tự như sau: ![]() Hãy nhập vài thông tin và click Submit. bạn sẽ nhận được câu thông báo Successful Registration! Để "chắc ăn", bạn có thể dùng bài thực hành trước. Chạy thử bạn sẽ thấy nội dung tblUser đã thêm một record mới. Chúng ta sẽ tiếp tục trong phần sau |
| < Trước | Tiếp > |
|---|