PHP 5/MySQL Programming- P20

PHP 5/MySQL Programming- P20: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 | 73 body h1 Hi User h1 if empty userName print HERE form Please enter your name input type text name userName br input type submit form HERE else print h3 Hi there userName h3 end body html This program begins by looking for the existence of a variable called userName. There is no userName variable the first time the program is called because the program was not called from a form. The empty function returns the value true if the specified variable is empty it returns false if it has a value. If userName does not exist empty userName evaluates as true. The condition empty userName is generally true if this is the first time this page has been called. If it s true the program should generate a form so the user can enter her name. If the condition is false that means somehow the user has entered a name presumably through the form so the program greets the user with that name. The key idea here is that the program runs more than once. When the user first links to the program creates a form. The user enters a value on the form and presses the submit button. This causes exactly the same program to be run again on the server. This time though the userName variable is not empty so rather than generating a form the program uses the variable s value in a greeting. Server-side programming frequently works in this way. It isn t uncommon for a user to call the same program many times in succession as part of solving a particular problem. You often use branching structures such as the if and switch statements to direct the program flow based on the user s current state of activity. Chapter 3 Controlling Your Code ith Conditions and Functions 74 PHP 5 MySQL Programming for the Absolute Beginner Responding to Checkboxes Now that you know how to use the if structure and the empty function you can work with checkboxes. Take a look at the following HTML code html head title Checkbox Demo title head body h1 Checkbox Demo h1 h3 Demonstrates checkboxes h3 form action .

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