Practical PHP and MySQLBuilding Eight Dynamic Web Applications phần 4

Nó là tốt hơn để có một số đơn giản, bảng nhỏ hơn. Nếu bạn lây lan dữ liệu của bạn qua một số các bảng nhỏ hơn, cơ sở dữ liệu của bạn sẽ thực hiện hiệu quả hơn, bởi vì nó sẽ không cần phải đi một cách mệt nhọc thông qua số lượng vô tận của các dữ liệu không liên quan. | CHAPTER 5 Discussion Forums 143 Create a new file called and add the form form action php echo pf_script_with_get SCRIPT_NAME method post table tr td Username td td input type text name username td tr tr td Password td td input type password name password td tr tr td td td input type submit name submit value Login td tr table form Don t have an account Go and a href Register a In the preceding code you might have noticed something odd in the action attribute of the form tag. A function called pf_script_with_get has been used to process the script name SCRIPT_NAME to detect which GET variables are added to the current page and then bolt them on to the action of the form. You need to add the GET variable to the action if you want to access it in the code that processes the form. This is fine if you know the name of the GET variable but if the variables could vary you need to detect them and add them. The reason you need this function is a result of the redirects. When a user clicks a link that requires her to be logged in such as the New Topic link the site should redirect to the login page. When the user has logged in she should then be redirected to the original link. This would be simple enough if there was just a single GET variable such as redirect but if you are trying to add a topic to a specific forum and are passing the Add Topic page an id there are two GET variables the page and the id of the forum. Instead of trying to hard code this it makes far more sense to detect which GET variables exist and add them automatically to the action part of the forum. The pf_script_with_get function is a custom function. Create a file called and add the following code php function pf_script_with_get script page script page page . foreach _GET as key val 144 Practical PHP and MySQL page page . key . . val . return substr page 0 strlen page -1 Within this function you pass the function the page to get the GET variable from .

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.