Adding a Delete Record Server Behavior

To complete the delete page, you must add a Delete Record server behavior. Although Dreamweaver 8 provides application objects for inserting records and updating records, it doesn't include an application object for deleting database records. After you add the Delete Record behavior, the record is deleted from the database when the user clicks the button on the delete page.

To add a Delete Record server behavior:


Open the confirmDelete.php page you used in the tasks in the previous section.


In the Application panel group, click the Server Behaviors tab to access the Server Behaviors panel.


Click the plus button, and select Delete Record from the contextual menu (Figure 12.51).

Figure 12.51. Choose Delete Record from the Server Behaviors menu to add a Delete Record server behavior.

The Delete Record dialog opens.


From the First Check If Variable Is Defined drop-down list, select Primary Key Value (Figure 12.52).

Figure 12.52. Select the primary key and form variable to specify the record to delete.

You'll set this value in the Primary Key Value field in Step 8.


From the Connection drop-down list, select the name of your connection to the travelclub database. Our connection is named connTravelClub.


From the Table drop-down list, select members.


From the Primary Key Column dropdown list, select id. Check the Numeric box, because the id value is a five-digit number.

The id field is the primary key for the member table. You'll use the primary key to select the record to delete.


From the Primary Key Value drop-down list, select Form Variable. Enter record in the box on the right.

The hidden form field named record contains the value of the primary key for the selected record.


In the After Deleting, Go To field, type the name of the confirmation page. We chose confirmation_delete.php. Click OK to close the dialog and insert the server behavior on your page.


Create a new PHP page, and name it con firmation_delete.php. Add a message to the page, like "Your record has been deleted from our travel club." Save the page.

The confirmation page opens when the user submits the form (Figure 12.53).

Figure 12.53. A confirmation page displays when the user submits the form to delete the record.


Open the select3.php page you created in "To select a record to delete," earlier in this chapter. Choose File > Preview in Browser to open the page in a browser.


Click a link to select a record to delete.

The record data displays on the confirmDelete.php page (Figure 12.54).

Figure 12.54. The record data from the selected record is shown on the confirmDelete page.


If you click the Confirm Delete button, the record will be deleted from the database.

You've created a set of pages for deleting a record: a select page, in which a user can select a record to delete; and a delete page, in which a user can view the data from the selected record and click the Confirm Delete button to delete this record. When the user clicks the button on the delete page, the confirmation page opens.


  • The Delete Record dialog is slightly different for ASP than for PHP and ColdFusion, but the process of creating a master page and a delete page is the same. For more details on filling out the Delete Record dialog using ASP, see Dreamweaver Help (F1).

Macromedia Dreamweaver 8 Advanced for Windows and Macintosh. Visual Quickpro Guide
Macromedia Dreamweaver 8 Advanced for Windows and Macintosh: Visual QuickPro Guide
ISBN: 0321384024
EAN: 2147483647
Year: 2004
Pages: 129
Authors: Lucinda Dykes © 2008-2017.
If you may any questions please contact us: