Apache Server 2 Bible Hungry Minds phần 7

và STDIN của chương trình CGI. Nếu kịch bản không để bất cứ điều gì đầu ra, STDOUT sẽ không được bao gồm. Để đăng nhập sản lượng CGI trong Apache, sử dụng các chỉ thị được mô tả trong các phần sau đây trong mô-đun mod_cgi, mà là một phần của phân bố chuẩn. | 450 Part III Running Web Applications table body html 8. As you can see the embedded PHP script is parsed out and the end user on the browser side does not even know which database or which user password was used to produce this page. If you have a lot of pages where you use the same MySQL database to display data elements using various queries you should use the i nclude function to simplify your code management tasks. For example Listing 15-12 shows a modified version of script that includes the i nclude function. Listing 15-12 php include usr local apache secrets mysql html head title Simple Query Script title head body table border 1 tr th Name th th Password th tr php sth mysql_query SELECT from stable dbh while myRow mysql_fetch_row sth printf tr td s td td s td tr myRow 0 myRow 1 table body html When the above script is accessed via the Web the resulting page is same as the one produced by . However here the script users a header file that contains the database connection script as shown below php host localhost user httpd passwd nolsecret database_name www Chapter 15 PHP and Apache 451 Stable users dbh mysql_connect host user Spasswd mysq1_se1ect_db database_name dbh By removing this script from each page that uses it you make it very easy to change the host name username password database name and table name. If you have 20 pages that use the same database and table you can now update the password once in the file and be done Securing PHP include files If you use include files as shown in the last section to store username password and other information such as database host name database name and table names that are not to be seen by users make sure you keep the include files in a safe directory where Web browsers cannot browse them. The best place is outside the document tree of the Web site. If the document root is www mysite htdocs then create a directory called www mysite .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.