TAILIEUCHUNG - Sams Teach Yourself PHP, MySQL and Apache in 24 Hours phần 7

Đặt những dòng này vào một file văn bản được gọi là danh sách , và đặt file này trong thư mục gốc tài liệu máy chủ web của bạn. Tiếp theo, bạn sẽ tạo ra kịch bản chính nó, tạo thành hy vọng sẽ được gọi là danh sách | Put these lines into a text file called listing and place this file in your Web server document root. Next you ll create the script itself which the form expects to be called listing . Listing User Login Script 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 php check for required fields from the form if _POST username _POST password header Location exit connect to server and select database conn mysql_connect localhost joeuser somepass or die mysql_error mysql_select_db testDB conn or die mysql_error create and issue the query sql select f_name l_name from auth_users where username _POST username AND password password _POST password result mysql_query sql conn or die mysql_error get the number of rows in the result set should be 1 if a match if mysql_num_rows result 1 if authorized get the values of f_name l_name f_name mysql_result result 0 f_name l_name mysql_result result 0 l_name set authorization cookie setcookie auth 1 0 0 prepare message for printing and user menu msg P f_name l_name is authorized p msg . P Authorized Users Menu msg . ul li a href secret page a u else redirect back to login form if not authorized header Location exit 39 40 HTML 41 HEAD 42 TITLE Listing User Login TITLE 43 HEAD 44 BODY 45 print msg 46 BODY 47 HTML Put these lines into a text file called and place this file in your Web server document root. In a moment you ll try it out but first let s examine what the script is doing. Line 3 checks for the two required fields from the form. They are the only two fields in the form username and password . If either one of these fields is not present the script will redirect the user back to the login form. If the two fields are present the script moves along to lines 9-11 which connect to the database server and select the database to use in preparation for issuing the SQL query to

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.