PHP 5/MySQL Programming- P41

PHP 5/MySQL Programming- P41: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 | 178 PHP 5 MySQL Programming for the Absolute Beginner The secret is to store the current answer key in a hidden form element and pass this element to another program. I created a form with two hidden fields. I stored the name of the puzzle in a field called puzzleName and the entire HTML of the answer key in a field called key. When the user presses the submit key it calls wordFindKey. f In the Real World Passing the answer key to another program is a kind of dirty trick. It works for a couple of reasons. First since the key field is hidden and the form sends data through the post method the user is unlikely to know that the answer to the puzzle is literally under his nose. Since I expect this program mainly to be used by teachers who would print the puzzle anyway this is fine. Even without the secrecy concerns it is necessary to pass the key data by post because it is longer than the 256 characters allowed by the get method. Sending the HTML-formatted answer key to the next program made the second program quite simple but there is another advantage to this approach It is difficult to send entire arrays through form variables. However by creating the HTML table all the array data was reduced to one string value which can be passed to another program through a form. Printing the Answer Key The wordFindKey program is very simplistic because all the work of generating the answer key was done by the Word Search program. wordFindKey has only to retrieve the puzzle name and answer key from form variables and print them out. Since the key has even been formatted as a table the wordFindKey program needn t do any heavy lifting. doctype html public - W3C DTD HTML EN html head title Word Find Answer Key title head body answer key for word find called from 179 print HERE center h1 puzzleName Answer key h1 key center HERE body html Summary In this chapter you see how important it is to put together data in meaningful ways. You look at a number of more powerful

Không thể tạo bản xem trước, hãy bấm tải xuống
18    102    1    29-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.