TAILIEUCHUNG - Phát triển web với PHP và MySQL - p 13

String Manipulation and Regular Expressions CHAPTER 4 95 LISTING Continued mail($toaddress, $subject, $mailcontent, $fromaddress); ? Bob’s Auto Parts - Feedback Submitted Feedback submitted Your feedback has been sent. 4 STRING MANIPULATION FIGURE Bob’s feedback form asks customers for their name, email address, and comments. Note that generally you should check that users have filled out all the required form fields using, for example, isempty(). We have omitted this from the script and other examples for the sake of brevity. In this script, you’ll see that we have concatenated the form fields together and used PHP’s mail() function to email them. | String Manipulation and Regular Expressions 95 Chapter 4 Listing Continued mail toaddress subject mailcontent fromaddress html head title Bob s Auto Parts - Feedback Submitted title head body h1 Feedback submitted h1 p Your feedback has been sent. p body html Figure Bob s feedback form asks customers for their name email address and comments. 4 Note that generally you should check that users have filled out all the required form fields using for example isempty . We have omitted this from the script and other examples for the sake of brevity. In this script you ll see that we have concatenated the form fields together and used PHP s mail function to email them to feedback@. We haven t yet used mail so we will discuss how it works. String Manipulation 96 Using PHP Part I Unsurprisingly this function sends email. The prototype for mail looks like this bool mail string to string subject string message string additional_headers The first three parameters are compulsory and represent the address to send email to the subject line and the message contents respectively. The fourth parameter can be used to send any additional valid email headers. Valid email headers are described in the document RFC822 which is available online if you want more details. RFCs or Requests For Comment are the source of many Internet standards we will discuss them in Chapter 17 Using Network and Protocol Functions. Here we ve used the fourth parameter to add a From address for the mail. You can also use to it add Reply-To and Cc fields among others. If you want more than one additional header just separate them by newlines n within the string as follows additional_headers From webserver@ n . Reply-To bob@ In order to use the email function set up your PHP installation to point at your mail-sending program. If the script doesn t work for you in its current form double-check Appendix A Installing PHP 4 and MySQL. Through this chapter we ll enhance

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.