PHP 5/MySQL Programming- P34

PHP 5/MySQL Programming- P34:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 143 All the fields sent to your program are automatically stored in a special associative array called _REQUEST. Each field name on the original form becomes a key and the value of that field becomes the value associated with that key. If you have a form with a field called userName you can get the value of the field by calling _REQUEST userName . The _REQUEST array is also useful because you can use a foreach loop to quickly determine the names and values of all form elements known to the program. The program source code illustrates how this is done doctype html public - W3C DTD HTML EN html head title Form Reader title head body h1 Form Reader h1 h3 Here are the fields I found on the form h3 print HERE table border 1 tr th Field th th Value th tr HERE Chapter 5 Better Arrays and String Handling foreach _REQUEST as field value print HERE tr td field td td value td tr HERE end foreach print table n body html 144 PHP 5 MySQL Programming for the Absolute Beginner Note how I stepped through the _REQUEST array. Each time through the foreach loop the current field name is stored in the field variable and the value of that field is stored in value. I use this script when I m debugging my programs. If I m not getting the form elements I expected from a form I put a foreach _REQUEST loop in at the top of my program to make sure I know exactly what s being sent to the program. Often this type of procedure can help you find misspellings or other bugs. In the Real World PHP provides some other variables related to _REQUEST. The HTTP_POST_VARS array holds all the names and values sent through a POST request and HTTP_GET_VARS array holds names and values sent through a get request. You can use this feature to make your code more secure. If you create variables only from the HTTP_POST_VARS array for example all input sent via the get method are ignored. This makes it harder for users to forge data by putting field names in the browser s address bar. Of course

Không thể tạo bản xem trước, hãy bấm tải xuống
109    135    1    28-03-2023
Đã 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.