1. Trang chủ
  2. » Công Nghệ Thông Tin

dreamweaver cs5 all in one for dummies phần 10 ppt

79 295 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 79
Dung lượng 2,24 MB

Nội dung

762 3. To select the form, click the form’s boundaries or click the <form> tag in the bottom-left corner of the Document window. Selecting the form lets you modify that form’s properties in the Properties inspector. 4. In the Properties inspector, enter a name for the form in the Form ID field. You probably want to use something descriptive, such as insert_form. Don’t set the Action or Method fields because the Insert Record server behavior sets these fields for you. 5. Add a text field by choosing Insert➪Form➪Text Field. You can also add other form objects, depending on the type of data that you want to insert into the database table. See Book II, Chapter 7 for more on the different form objects. 6. In the Input Tag Accessibility Attributes dialog box, enter a descrip- tive ID and a text label. 7. (Optional) Tweak the Style and Position settings as desired. 8. Click OK. 9. For each column that you allow the user to add data to, repeat Steps 5–8. For the employee table example, we added each field but arranged the fields in a slightly different order on the form. 10. Press Enter (Windows) or Return (Mac) to insert a new line so that the element appears on a separate line. You can also use a table element to align your fields (see Book II, Chapter 7 for more information). 11. Insert a submit button on the page by choosing Insert➪Form➪Button. If the Input Tag Accessibility Attributes dialog box appears, click Cancel. 12. With the button selected, change the Value text in the Properties inspector to Insert. The example form looks like Figure 3-4. Adding the Insert Record server behavior You have to add the Insert Record server behavior to your page so that it can process the data in the form submission. You must have an active database connection before you can add the Insert Record server behavior. See Book VII for details on setting up a database connection. Building a Record Insert Page Block by Block 55_610770-bk09ch03.indd 76255_610770-bk09ch03.indd 762 5/6/10 1:21 PM5/6/10 1:21 PM Book IX Chapter 3 Building Record Insert Pages and Restricting Site Access 763 Figure 3-4: The completed form. To add the Insert Record server behavior, follow these steps: 1. In the Server Behaviors panel, click the plus (+) icon and select Insert Record in the drop-down list that appears. The Insert Record dialog box appears. 2. Select your form in the Submit Values From drop-down list. 3. In the Connection drop-down list, select a database connection that contains the table that you want to insert data into. 4. In the Insert Table drop-down list, select the database table that you want to insert a record into. The database columns appear in the Columns section, as shown in Figure 3-5. Depending on your dynamic page type, the Insert Record dialog box may appear slightly different. For example, ColdFusion calls the Connection field a data source and includes options for Username and Password database fields. However, these differences don’t change the following steps. Building a Record Insert Page Block by Block 55_610770-bk09ch03.indd 76355_610770-bk09ch03.indd 763 5/6/10 1:21 PM5/6/10 1:21 PM 764 5. (Optional) To modify the associated database column or data type of a field, select the column from the column list and then modify the fol- lowing fields in the dialog box: • Value: Select the form field. Each form field appears in the list. • Submit As: Select the data type. The data type that you select here should mirror the database column data type. The types are text, integer, date, and check box formats. Dreamweaver automatically links the form fields that have the same name as the database field. Figure 3-5: Use the Insert Record dialog box to choose which fields supply values from the form to the database table. 6. For each field that you need to change, repeat Step 5. 7. In the After Inserting, Go To text field, enter the page that you want to go to after inserting the record. Or click the Browse button and select a file. For the ASP.NET dynamic page type, you have a choice also for the On Failure, Go To text box and a Display Debugging Information check box. You fill in these fields to display debugging information or redirect a user if the record insert fails. The rest of the dialog box works the same as the other document types. 8. Click OK. Dreamweaver adds the server behavior to the page. You now have a complete page. Users can fill out the fields on the page and then click the submit button. You can make any visual changes to the form by using Dreamweaver’s tools for changing fonts, colors, and placement. Building a Record Insert Page Block by Block 55_610770-bk09ch03.indd 76455_610770-bk09ch03.indd 764 5/6/10 1:21 PM5/6/10 1:21 PM Book IX Chapter 3 Building Record Insert Pages and Restricting Site Access 765 Testing Your Record Insert Page After you create a record insert page (see “Building a Record Insert Page Block by Block” section, earlier in this chapter), you probably want to test your page. Follow these steps to do so: 1. Open the Record Insert page. 2. Choose File➪Preview in Browser➪Name of Browser. 3. When Dreamweaver asks if it’s okay to copy files to your testing site, click OK. Your browser launches and displays the Record Insert page. 4. Enter some sample data into the fields. Figure 3-6 shows some test data for the employee table. Figure 3-6: Entering data into the Record Insert page. 5. Click the Insert Record button. When the data is added successfully, the browser opens the success page. Be sure that both your Record Insert page and success page transfer to the testing server. If not, when you click the button on the insert page, you get a Page Not Found error message. The success page in our example simply contains the text Inserted Successfully. Testing Your Record Insert Page 55_610770-bk09ch03.indd 76555_610770-bk09ch03.indd 765 5/6/10 1:21 PM5/6/10 1:21 PM 766 If you want to double-check that the insert worked, follow these steps: 1. Open the Databases panel. 2. Expand the database you are working with by clicking the arrow. 3. Expand the Tables item to display the table you are working with. 4. Right-click the table on the page. 5. Choose View Data from the pop-up menu. The View Data dialog box appears, as shown in Figure 3-7. Figure 3-7: The View Data dialog box shows the newly inserted data. In the dialog box, you can see that the data was inserted correctly into the table. Building a Login Page A login page enables registered users to log in to a Web site. Dreamweaver CS5 comes with a sample design of a login page. You can also design your own. The following sections show you how to complete the steps to building your own login page. Building a Login Page 55_610770-bk09ch03.indd 76655_610770-bk09ch03.indd 766 5/6/10 1:21 PM5/6/10 1:21 PM Book IX Chapter 3 Building Record Insert Pages and Restricting Site Access 767 Setting up a database table If you set up the employee entry page, as described earlier in the chapter, you’ve already created this table. Creating the HTML form on the login page If you want to design your own login page, first you need to create a new page and add an HTML form with a username text box, a password text box, and a submit button. This process is similar to the process of adding a form to a data entry page. Adding a Log In User server behavior to the page After adding a form to your login page (as described in the preceding sec- tion), the final step is to add the Log In User server behavior, which checks to make sure that the user entered a valid username and password. To add the Log In User server behavior to your login page, open the page and follow these steps: 1. In the Server Behaviors panel, click the plus (+) icon and choose User Authentication➪Log In User. The Log In User dialog box appears. 2. In the Get Input From Form field, select the form used on the login page. 3. In the Username Field and Password Field text boxes, select the appro- priate form fields. 4. If you are using ColdFusion, enter your username and password. 5. In the Table drop-down list, select the database table that you will check the form fields against. We selected the users table. 6. In the Username Column and Password Column drop-down lists, spec- ify the table columns for the username and password. For example, the users table that we selected in Step 5 contains user- name and password columns, so we selected those columns. 7. In the If Login Success, Go To text box, enter the name of the page to open if the user logs in successfully. Or you can click the Browse button and select the page. Building a Login Page 55_610770-bk09ch03.indd 76755_610770-bk09ch03.indd 767 5/6/10 1:21 PM5/6/10 1:21 PM 768 8. In the If Login Fails, Go To text box, enter the name of the page to open if the user is unable to log in. Or you can click the Browse button and select the page. 9. Indicate whether you want to grant access to this page based on just the username and password, or based on the authorization level as well. Having multiple authentication levels provides more flexibility for segregated access to information but also comes at the cost of added complexity (and time administering your user’s levels and categorizing information). Most people can get by without setting up multiple access levels to their sites. 10. Click OK. Your login page is now complete. Restricting Access to Your Pages If you have a Web page that you don’t want all users to be able to view, you can restrict access to it. To do this, you add the Restrict Access to Page server behavior to the page so that only authorized users can view the page. If an unauthorized user attempts to open the restricted page, the user is redirected to another page. Here are a few examples of when restricted access may be useful: ✦ You have a page that you want to be viewed only by users with Administrator privileges. ✦ You want to make sure that users log in before they can view a specific page. ✦ You want to review newly registered users before allowing them to access members-only pages. To restrict access to a page, you need to do the following tasks: ✦ Add the Restrict Access to a Page server behavior to that page. ✦ If you want to use authorization levels to further restrict page access, you need to add a column to your user database table to maintain infor- mation about which access privileges each user is entitled to. Restricting Access to Your Pages 55_610770-bk09ch03.indd 76855_610770-bk09ch03.indd 768 5/6/10 1:21 PM5/6/10 1:21 PM Book IX Chapter 3 Building Record Insert Pages and Restricting Site Access 769 Follow these steps to restrict access to a page: 1. Open the page you want to restrict access to. 2. In the Server Behaviors panel, click the plus (+) icon and choose User Authentication➪Restrict Access to Page. The Restrict Access to Page dialog box appears. 3. In the Restrict Based On area, select one of the following options: ✦ Username and Password: Select this option if you want only users with a valid username and password to access the restricted page. ✦ Username, Password, and Access Level: Select this option if you want only users with specific access privileges to be able to view the page. Specify one or more authorization levels for the page — for example, Administrator. 4. In the If Access Denied, Go To text box, enter the name of the page to open if an unauthorized user attempts to open the restricted page. 5. Click OK. Dreamweaver adds a server behavior to the page ensuring that only autho- rized users can access the page. Restricting Access to Your Pages 55_610770-bk09ch03.indd 76955_610770-bk09ch03.indd 769 5/6/10 1:21 PM5/6/10 1:21 PM 770 Book IX: Developing Applications Rapidly 55_610770-bk09ch03.indd 77055_610770-bk09ch03.indd 770 5/6/10 1:21 PM5/6/10 1:21 PM Chapter 4: Developing Record Update and Delete Pages In This Chapter ✓ Creating record update pages ✓ Trying out your record update page ✓ Deleting records by using delete pages ✓ Putting your delete page to the test I n previous chapters in this minibook, we’ve shown you how to browse, search, and insert data. But before you go away thinking that you’ve dis- covered everything you need to know about Web apps, we need to tell you — in the words of a late-night television infomercial — but wait, there’s more! The record update and delete operations are the last two database func- tions commonly used in dynamic database sites. For example, suppose that employees at your company can view their employee data online. Over time, they may want to change their employment details. Or perhaps an H.R. administrator may need the ability to delete an employee record. In any case, you need to give users the ability to update and delete database records from a Web page, which is what this chapter is all about. Building an Update Page Before users can update a record, they need to be able to search for the record that they want to update. Therefore, you need to create a search page and a results page. (See Book IX, Chapter 2 for full details on how to create and work with search and results pages.) Additionally, you need to create an update page so that users can enter the data for updating the record. Here’s a closer look at the three pages that you need to create: ✦ Search page: This page allows users to search for a record that they want to update. For example, in the case of an employee record, the search page simply searches the employee that’s logged in because employees can’t modify other employee information. ✦ Results page: This page displays the record in a form. The form defaults to the values currently in the database (before the update) and has an update button. 56_610770-bk09ch04.indd 77156_610770-bk09ch04.indd 771 5/6/10 1:21 PM5/6/10 1:21 PM [...]... property, 210 deleting style, 225 design time style sheets, 245 disabling/enabling CSS property, 210 editing in All mode, 223–224 in Current mode, 224 icon, 210 enabling/disabling properties, 225–227 exporting internal style to external style sheet, 242–243 external, 204 ID styles, 213–214 inline styles, 207–208 internal styles, 204–206 layout, 64 new rule, 210 overview, 201–203 57_ 6107 70-bindex.indd 795... BrandGopher, 350 57_ 6107 70-bindex.indd 794 Bridge accessing, 346 inserting file from, 347 launching Dreamweaver from, 347 launching from Dreamweaver, 347 using, 346 web site, 346 Brightness and Contrast tool, 106 broken links, 492 Browser Compatibility report editing Ignored Issues List, 490 error, 489 ignoring specific errors, 490 jumping to code in, 490 jumping to next or previous error in, 490 message,... dialog box, 570–571, 573 Administrator Password dialog box, 573 Adobe After Effects, 132 Adobe AIR, 349–350 Adobe AIR extension for Dreamweaver, 349–350 Adobe AIR Marketplace, 350 Adobe Bridge accessing, 346 inserting file from, 347 launching Dreamweaver from, 347 launching from Dreamweaver, 347 using, 346 web site, 346 5/6 /10 1:21 PM 792 Dreamweaver CS5 All- in- One For Dummies Adobe BrowserLab, 144,... 5/6 /10 1:21 PM 794 Dreamweaver CS5 All- in- One For Dummies behaviors (continued) Swap Image, 422–424 Swap Image Restore, 424–425 third-party, 425–428 updating, 392–393 using, 282 Validate Form, 425 Behaviors panel, 389–390 Bind to Dynamic Source (lightning bolt) icon, 773 Bindings panel, 676 _blank option (frames), 455 Blind (Spry Effect), 401 block snippets, 300, 301 blocks compact, 234 displaying,... source formatting to file, 514–515 applying source formatting to selection in file, 515–517 cleaning up Word HTML, 504–506 color, 511 consistency in HTML/XHTML, 508– 510 Copy/Paste preferences, 502–504 format advanced formatting, 513 case rules for tags and attributes, 512 default attribute case, 512 default tag case, 512 indent, 511 line break type, 512 tab size, 511 TD tag, 512 formatting issues, 502 hints... Dreamweaver CS5 All- in- One For Dummies cells (continued) spacing, 154, 158 splitting, 160 width, 164 centimeters, 84 Certified Service Providers, 521 CFCs (ColdFusion Components) access, 722 benefits of, 717 component directory, 721 conditional code block execution, 723 creating, 720–722 display name, 720 extends, 721 hint, 720–721 including in Web pages, 718–720 name, 721 return type, 722 using, 717–718... preferences, setting, 510 rewriting, 513–514 spelling, grammar, and readability, 506–508 Code Navigator, 75, 227, 246–247 code snippets creating with graphics, 309– 310 with Wrap Selection option, 306–308 deleting, 312 5/6 /10 1:21 PM Index editing, 312 JavaScript snippet, 304–306 managing, 312 overview, 301 sharing, 311 text snippets, 302–303 Code view adding text in, 75 editing text in, 76–77 Macintosh location... information, 651 deleting database connection, 659 Developer Center, 652 editing database connection using ColdFusion Administrator, 658–659 using Dreamweaver, 657–658 Help, 32 overview, 651–652 specifying RDS login information, 653–654 ColdFusion Administrator, 654–656 ColdFusion Components (CFCs) accessing, 722 benefits of, 717 component directory, 721 conditional code block execution, 723 creating,... 57_ 6107 70-bindex.indd 797 797 hint, 720–721 including in Web pages, 718–720 name, 721 return type, 722 using, 717–718 ColdFusion Markup Language (CFML), 471 colon (:), 211 colors hexadecimal numbers, 83 palette, 331 Web-safe, 83 columns adding, 162 deleting, 163 merging, 158–159 multiple, adding, 162–163 splitting, 158–159 in tables, number of, 153 commands deleting, 317 playing, 315–317 recording,... object in Dreamweaver, but remember to not move them outside the form’s boundaries (See Book II, Chapter 7 for more on form objects.) 56_ 6107 70-bk09ch04.indd 778 5/6 /10 1:21 PM Testing Your Update Page 779 Book IX Chapter 4 Developing Record Update and Delete Pages Figure 4-6: The Document window now contains the update form Testing Your Update Page You can test your results page by previewing it in a . the form by using Dreamweaver s tools for changing fonts, colors, and placement. Building a Record Insert Page Block by Block 55_ 6107 70-bk09ch03.indd 76455_ 6107 70-bk09ch03.indd 764 5/6 /10 1:21. steps to building your own login page. Building a Login Page 55_ 6107 70-bk09ch03.indd 76655_ 6107 70-bk09ch03.indd 766 5/6 /10 1:21 PM5/6 /10 1:21 PM Book IX Chapter 3 Building Record Insert Pages. connection. Building a Record Insert Page Block by Block 55_ 6107 70-bk09ch03.indd 76255_ 6107 70-bk09ch03.indd 762 5/6 /10 1:21 PM5/6 /10 1:21 PM Book IX Chapter 3 Building Record Insert Pages and Restricting

Ngày đăng: 08/08/2014, 20:20