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

Khi bạn sử dụng khách hàng, thông báo lỗi được hiển thị trong một cửa sổ pop-up Javascript hộp một tính năng tốt đẹp trong HTML_QuickForm. Với hình thức đầy đủ và xác nhận gia tăng, thêm mã để xác định hình thức được xử lý như thế nào: | CHAPTER 11 Building a News Web Site 455 The final two parameters are both optional. The fourth can be used to specify extra rule information this is unnecessary here so null is specified and the fifth indicates whether the client or server should process the form. When you use client error messages are displayed in a Javascript pop-up box another nice feature in HTML_QuickForm. With the form complete and validation added add the code that determines how the form is processed form- addRule subject Please enter a subject required null client form- addRule body Add some body text required null client if form- validate form- freeze form- process process_data false insertid mysql_insert_id header Location . config_basedir . id . insertid This if block checks to see if the form validates by running the validate method. If this is the case the form is first frozen with freeze to prevent any further user input. The process function then indicates which function should be used to process the form. This function specifies the name of the function in this case process_data remember to leave off the brackets and the false parameter specifies whether uploaded files should be processed in this case not . After process_data is run the id from the INSERT query is stored in ĩinsertid and used in the header to redirect to with the correct id. The preceding code assumes that the form has been submitted and validates. If not display the form header Location . config_basedir . id . ĩinsertid else require echo h1 Add story h1 form- display Here you use the display method to display the form for the user. 456 Practical PHP and MySQL The final chunk of code to add is process_data the function that processes the form form- displayO function process_data values sql INSERT INTO stories cat_id poster_id dateposted subject body VALUES . values cat_id . . _SESSION SESS_USERID . NOW . . pf_fix_slashes values subject . . . pf_fix_slashes values

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
36    692    5    28-04-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.