PHP for Absolute Beginners PHẦN 9

Tại thời điểm này, bạn có một mảng có chứa các mục của bạn đã sẵn sàng cho đầu ra. Bạn sử dụng một vòng lặp foreach để hiển thị mỗi mục. Bắt đầu bằng cách tạo ra một mục với một tiêu đề, mô tả, và một liên kết. Thêm bước để thoát khỏi tất cả các thực thể HTML trong mô tả của bạn, | CHAPTER 10 ADDING A COMMENTING SYSTEM TO YOUR BLOG If set store the entry from which we came loc isset _POST url _POST url . If the user clicked Yes continue with deletion if _POST confirm Yes Include and instantiate the Comments class include_once comments new Comments Delete the comment and return to the entry if comments- deleteComment _POST id header Location . loc exit If deleting fails output an error message else exit Could not delete the comment. If the user clicked No do nothing and return to the entry else header Location . loc exit else header Location . exit Download at 309 CHAPTER 10 ADDING A COMMENTING SYSTEM TO YOUR BLOG At this point you can delete comments from the database thus removing them from your entry display. You can test this out by deleting your test comment. Navigate to the entry that you we entered for the comment in a browser then click the delete link. Next click Yes to confirm that you want to delete the comment. This takes you back to the entry but the comment is no longer there. Instead you see the default message There are no comments for this entry see Figure 10-6 . Figure 10-6. After deleting your test comment you see this default message Summary In this chapter you learned how to add an interactive element to your blog by allowing users to comment on your blog entries. In doing so you also learned a little more about object-oriented programming. In the next chapter you ll learn how to build a login system that lets you hide administrative controls from users who aren t logged in giving you better control over your blog. 310 Download at C H A P T E R 11 Adding Password Protection to Administrative Links One of the last things you need to add before you can call your blog web-ready is to hide the administrative links from users who aren t authorized to view them. In this chapter you ll learn how to build a system that lets you create administrators and require them to log in with a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
86    90    2    01-05-2024
Đã 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.