Danh mục

Ebook MySQL/PHP database applications: Part 2

Số trang: 191      Loại file: pdf      Dung lượng: 3.48 MB      Lượt xem: 20      Lượt tải: 0    
Xem trước 10 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

This part cover several topics of interest to the MySQL/PHP developer. In the appendixes, you will find installation and configuration instructions, quick reference guides to PHP and MySQL functions, a regular expressions overview, and guides to MySQL administration. In addition, there are a few helpful resources, snippets of code, and instructions on using the CD-ROM.
Nội dung trích xuất từ tài liệu:
Ebook MySQL/PHP database applications: Part 2 3537-4 AppA.f.qc 12/15/00 15:26 Page 405 Appendix A HTML Forms IF YOU WANT YOUR APPLICATIONS to take user data, you are going to need a place for them to enter the information. That requires HTML forms. HTML forms are easy enough to work with. There are several commonly used input types, and in browsers that make use of HTML 4.0 and Cascading Style Sheet there are some techniques that you can use to make your forms a bit fancier. A full discussion of everything you can do with forms is beyond the scope of this book. If you need more information on forms and how they can work with CSS or JavaScript, or some of the newer browser-specific form types, check out the documentation at http://microsoft.com or http://mozilla.org. Form Basics Each form is delimited by opening and closing tags. The tag takes the following attributes: x action — This attribute specifies the URL of the page that a form will be sent to for processing. It can contain a relative URL (e.g., “myscript.php” or “../myfolder/myscript”) or a complete URL (e.g., http://www.mydomain/ myscript.php”). x method — This attribute indicates the HTTP request type the browser will send to the server. It must be set to either GET or POST. If you set it to GET, the name=value pairs will appear in the browser location bar (e.g., http://mypage.com?name1=value1&name2=value2). The advantage of using GET is that results can be bookmarked in the browser. The disad- vantage is that the variables you send will be more transparent. If you set this attribute to POST the name=value pairs will not be visible. The default value is GET. x name — This attribute is most useful for addressing portions of a form through JavaScript. The form name is not sent to the server when the form is submitted. x enctype — The default is “application-x-www-form-urlencoded”, and this will normally be fine. But if you are uploading files (using , you should use “multipart/form-data”. 405 3537-4 AppA.f.qc 12/15/00 15:26 Page 406 406 Part V: Appendixes A typical form shell will look something like this: ... Input Types Most of the work in your forms will be done by the input types. An input tag and the type attribute will determine what kind of form element is rendered in your browser. Every input type must have a name attribute. That’s how you’re going to pass variables to your scripts, so make sure you don’t forget them. (To be absolutely accurate, you don’t need to supply name attributes to submit and reset buttons.) As a quick example, the following would create a simple form with a single text box and a submit button. The text box has the default value of “hello there”, as shown in Figure A-1. Figure A-1: Simple HTML form 3537-4 AppA.f.qc 12/15/00 15:26 Page 407 Appendix A: HTML Forms 407 The input types are as follows. Note that different input types have different attributes associated with them. Each of them takes a name attribute. x Text — This type is shown in the above example. It can take these attributes: s Size, which indicates the length of the box rendered in the Web browser. s Maxlength, which limits the number of characters that can be input into the field. Keep in mind that older browsers will ignore maxlength, and even in newer browsers, you should not rely on this attribute to limit uploads. Check your upload_max_filesize item in your php.ini to set the limit on the server. s Value, which is the default value in the box. The user can override it by typing in different information. x Password — This type is identical to the text field, except that the text that is typed into the box is shown as asterisks. x Hidden — This type does not render on the screen. It is very useful for passing values between pages. The name and value attributes are all you need with hidden fields. Consider using hidden fields if you’re uncomfortable with cookies or sessions. Note that by simply viewing the source of your Web page, a savvy user will be able to see your ...

Tài liệu được xem nhiều: