PHP and MySQL Web Development - P12

PHP and MySQL Web Development - P12: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 22 Chapter 1 PHP Crash Course Let s look at an example. Because the long style variable names are somewhat cumbersome and rely on a variable type known as arrays which we will not cover properly until Chapter 3 Using Arrays we will start by creating easier-to-use copies. To copy the value of one variable into another you use the assignment operator which in PHP is an equal sign .The following line of code will create a new variable named tireqty and copy the contents of HTTP_POST_VARS tireqty into the new variable tireqty HTTP_POST_VARS tireqty Place the following block of code at the start of the processing script. All other scripts in this book that handle data from a form will contain a similar block at the start. As it will not produce any output it makes no difference whether you place this above or below the html and other HTML tags that start your are generally placing this block at the very start of the script to make it easy to find. php create short variable names tireqty HTTP_POST_VARS tireqty oilqty HTTP_POST_VARS oilqty sparkqty HTTP_POST_VARS sparkqty This code is creating three new variables tireqty oilqty and sparkqty and setting them to contain the data that was sent via the POST method from the form. To make the script start doing something visible add the following lines to the bottom of your PHP script echo p Your order is as follows p echo tireqty. tires br echo oilqty. bottles of oil br echo sparkqty. spark plugs br If you now load this file in your browser the script output should resemble what is shown in Figure actual values shown will of course depend on what you typed into the form. A couple of interesting things to note in this example are discussed in the following subsections. String Concatenation In the script we used echo to print the value the user typed in each of the form fields followed by some explanatory text. If you look closely at the echo statements you will see that the variable name and following text have

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
27    8    1    28-03-2024
283    512    1    28-03-2024
Đã 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.