Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Beginning PHP6, Apache, MySQL Web Development- P18:Welcome to Beginning PHP6, Apache, MySQL Web Development , your new trusty resource for assistance in creating your own dynamic web sites. There are a lot of technologies available that can be used to deliver great web sites, and we ’ re glad you chose the Apache/MySQL/PHP (sometimes referred to simply as AMP) approach. You may or may not have had a taste of these three components in the past, but either way we ’ re confident that you will be impressed with the power that lies within them | Chapter 14 Mailing Lists 6. Click the link at the bottom of the page to send a message to your users. A new page appears where you can compose a new message and send it either to a single mailing list or to the users of all the mailing lists as shown in Figure 14-2. Since you just created these pages you don t have any users yet. You can compose a message but it won t go to anyone. You need to create the user pages which you ll do shortly. Figure 14-2 How It Works A common practice is to post a form back to itself and you certainly could have done that here. In fact you have done this in earlier projects in this book. When your page contains data that needs to be inserted into a database however you need to think twice about a self-posting form. If the user were to refresh or reload the page all of your database functions would run again and that could be disastrous. You could end up with duplicate data or delete records you didn t mean to delete. To minimize that probability you post to a separate script called ml_admin_transact.php. This page handles all of the necessary database transactions and then directs you back to the page from which you came. No harm will come to your database if the user reloads the page at that point. To accommodate having several forms post their information to a central transaction script all of your submit buttons have the same name action but each has a different value. The transaction script can check the value of the _POST action variable to see which button was pressed and perform the appropriate actions. 481 Part II Comic Book Fan Site In ml_admin.php you present a form that collects information to be sent to ml_admin_transact .php. The first portion of the form is used to create new mailing lists and is basic HTML because it is always visible. form method post action ml_admin_transact.php p label for listname Add Mailing List label br input type text id listname name listname maxlength 100 input type submit name action value .