Giải pháp thiết kế web động với PHP - p 15

BRINGING FORMS TO LIFE This sets a new condition that takes priority over the original warning message by being considered first. It checks if the $_POST array contains any elements—in other words, the form has been submitted—and if $suspect is true. The warning is deliberately neutral in tone. There s no point in provoking attackers. More important, it avoids offending anyone who may have innocently used a suspect phrase. 6. Save , and test the form by typing one of the suspect phrases in one of the fields. You should see the second warning message, but your input won t be. | BRINGING FORMS TO LIFE This sets a new condition that takes priority over the original warning message by being considered first. It checks if the _POST array contains any elements in other words the form has been submitted and if suspect is true. The warning is deliberately neutral in tone. There s no point in provoking attackers. More important it avoids offending anyone who may have innocently used a suspect phrase. 6. Save contact .php and test the form by typing one of the suspect phrases in one of the fields. You should see the second warning message but your input won t be preserved. You can check your code against and in the ch05 folder. Sending email Before proceeding any further it s necessary to explain how the PHP mail function works because it will help you understand the rest of the processing script. The PHP mail function takes up to five arguments all of them strings as follows The address es of the recipient s The subject line The message body A list of other email headers optional Additional parameters optional Email addresses in the first argument can be in either of the following formats user@ Some Guy user2@ To send to more than one address use a comma-separated string like this user@ another@ Some Guy user2@ The message body must be presented as a single string. This means that you need to extract the input data from the _POST array and format the message adding labels to identify each field. By default the mail function supports only plain text. New lines must use both a carriage return and newline character. It s also recommended to restrict the length of lines to no more than 78 characters. Although it sounds complicated you can build the message body automatically with about 20 lines of PHP code as you ll see in PHP Solution 5-6. Adding other email headers is covered in detail in the next section. Many hosting companies now make the fifth argument

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.