+ All Categories
Home > Documents > Creating Dynamic Database-Driven Sites with Dreamweaver

Creating Dynamic Database-Driven Sites with Dreamweaver

Date post: 30-Dec-2015
Category:
Upload: ciaran-guy
View: 31 times
Download: 4 times
Share this document with a friend
Description:
Creating Dynamic Database-Driven Sites with Dreamweaver. ASP PHP JSP ColdFusion. Lloyd Rieber. Workshop Home Page: http://projects.coe.uga.edu/workshop/rieber/. Last updated on November 20, 2008. Recommended: Get and Install the Dreamweaver Extension 'Go To Detail Extension for PHP'. - PowerPoint PPT Presentation
Popular Tags:
75
Creating Dynamic Database- Driven Sites with Dreamweaver Lloyd Rieber Workshop Home Page: http://projects.coe.uga.edu/workshop/ rieber/ ASP PHP JSP ColdFusion Last updated on November 20, 2008
Transcript
Page 1: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating Dynamic Database-Driven Sites with Dreamweaver

Lloyd Rieber

Workshop Home Page:http://projects.coe.uga.edu/workshop/rieber/

ASPPHPJSP

ColdFusion

Last updated on November 20, 2008

Page 2: Creating Dynamic Database-Driven Sites  with Dreamweaver

Recommended: Get and Install the Dreamweaver Extension

'Go To Detail Extension for PHP'

• Here’s the URL:

http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=627434

(Link is on workshop home page.)

Page 3: Creating Dynamic Database-Driven Sites  with Dreamweaver

Workshop Agenda

• Welcome and introductions• Seeing the power of a dynamic web site in

education– Online Introduction to Instructional Design

• Seeing/doing it: Building a small dynamic “people” web site– List current people, add new person, update existing

person

• Advanced topics– Session variables, PHP scripting, Automated Email

Page 4: Creating Dynamic Database-Driven Sites  with Dreamweaver

Some of Lloyd’s Examples of Using Online Databases

• Online Introduction to Instructional Design• Other examples

– Project Promote– Peer Financial Counseling– WWILD Team– Introduction to Computers in Education

(Online Course)– EDIT 6170 IDA Library– IDD Portfolio Management

Page 5: Creating Dynamic Database-Driven Sites  with Dreamweaver

http://www.nowhereroad.com/instructionaldesign

Page 6: Creating Dynamic Database-Driven Sites  with Dreamweaver

Program Flowchart

list.php

insert.phpupdate.php

update_record_reply.htm new_record_reply.htm

Update Record Insert Record

Page 7: Creating Dynamic Database-Driven Sites  with Dreamweaver

Here are the files we will eventually create…

Page 8: Creating Dynamic Database-Driven Sites  with Dreamweaver

Client requests PHP File

Client

Server

Server returns HTML text to client

Server locates the PHP file on the hard drive and parses it, removing all PHP script and replacing it with HTML text

Client/Server Interaction for PHP Files

Adapted from Mitchell & Atkinson (2000)

Page 9: Creating Dynamic Database-Driven Sites  with Dreamweaver

How Databases Work

A 15-Minute Primer

Page 10: Creating Dynamic Database-Driven Sites  with Dreamweaver

“Flat” Database Structure

Database

Record Record Record

Field Field Field

Page 11: Creating Dynamic Database-Driven Sites  with Dreamweaver

“Flat” Database Structure

Studio People

Lloyd Ike Greg

Database ID Name Course

Page 12: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 13: Creating Dynamic Database-Driven Sites  with Dreamweaver

Relational Database StructureA Collection of Databases (tables) that connect (relate) to each other

Orders

Order1 Order2 Order3

People_ID Order_ID Book_Title Price

People

John Mary Jane

People_ID Name Address Email

Page 15: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 16: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 17: Creating Dynamic Database-Driven Sites  with Dreamweaver

Working with mySQL DatabasesphpMyAdmin

http://projects.coe.uga.edu/pma

Page 18: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 19: Creating Dynamic Database-Driven Sites  with Dreamweaver

Step 1: Make a root folder

Step 2: Create a folder inside it named:yourLastname

Getting Ready to Work with Dreamweaver

Page 20: Creating Dynamic Database-Driven Sites  with Dreamweaver

Step 3: Launch Dreamweaver and define a new site that points to the root folder.

Launch Dreamweaver

Page 21: Creating Dynamic Database-Driven Sites  with Dreamweaver

Remote Server Information

Be sure to “Test” your connection before proceeding.

Password:

(this will be changed within a few days)

Notice that this server needs a Secure FTP connection.

eu3$@93!

Page 22: Creating Dynamic Database-Driven Sites  with Dreamweaver

Testing Server Information

Be sure to “Test” your connection before proceeding.

Double-check that this URL is correct. (On some servers, you will need to remove server-side pathways, such as “wwwroot”, from the URL Prefix.

Page 23: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating a Simple Search/Results Page Set

Page 24: Creating Dynamic Database-Driven Sites  with Dreamweaver

Make a new file called “list.php”

Add a 2 X 4 table and format accordingly:

Page 25: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating a Data ConnectionGo to the Application Panel, click on “Databases” tab, then follow the directions…

Naming convention:

connDescriptive

Use “connLastName” (for reasons I’ll explain)

Page 26: Creating Dynamic Database-Driven Sites  with Dreamweaver

Notice that a folder titled “Connections” has been automatically created in your root folder.

Creating a Data Connection

Page 27: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating a New RecordSetGo to the Application Panel, click on “Bindings” tab, then follow the directions…

Naming convention:

rsDescriptive

Use “rsPeople”

Always testing the connection is a good habit to develop

Page 28: Creating Dynamic Database-Driven Sites  with Dreamweaver

Insert Dynamic Data into Document

Page 29: Creating Dynamic Database-Driven Sites  with Dreamweaver

Click on “Server Behavior” Tab and Note What you Find

Page 30: Creating Dynamic Database-Driven Sites  with Dreamweaver

Repeating a Region with Multiple DataStep 1: Select table row <tr> as the region to repeat.

(Repeat Region is always linked to a specific HTML tag.)

Step 2: Select “Repeat Region” from Server Behaviors.

Page 31: Creating Dynamic Database-Driven Sites  with Dreamweaver

Upload and Test the PageChoose to “include dependent files” (only necessary the first time you upload).

Reason: The “Connections” file needs uploaded too.

http://projects.coe.uga.edu/workshop/rieber/list.php

Your last name goes here

Page 32: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating an Insert Page

Page 33: Creating Dynamic Database-Driven Sites  with Dreamweaver

Create a New Document…

insert.php

Select from menubar…

Insert

Data Objects >

Insert Record >

Record Insertion Form Wizard

Page 34: Creating Dynamic Database-Driven Sites  with Dreamweaver

Filling out the Dialog Box

Remove from list

Page 35: Creating Dynamic Database-Driven Sites  with Dreamweaver

Form is Created… Feel free to modify

Page 36: Creating Dynamic Database-Driven Sites  with Dreamweaver

Create “new_record_reply.html”

Click here to view all the records.

Page 37: Creating Dynamic Database-Driven Sites  with Dreamweaver

Upload and Test

Page 38: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 39: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating an Update/Delete Page

Page 40: Creating Dynamic Database-Driven Sites  with Dreamweaver

Reminder: Get Extension 'Go To Detail Extension for PHP'

• Here’s the URL:

http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=627434

(Link is on workshop home page.)

Page 41: Creating Dynamic Database-Driven Sites  with Dreamweaver

What If I Didn’t Get the Extension?

• Then you will have to enter the code manually:

Generic:

filename.php?recordID=<?php echo $row_recordsetName['fieldName']; ?>

Actual for the example to follow:

update.php?ID_people=<?php echo $row_rsPeople['ID_people']; ?>

Page 42: Creating Dynamic Database-Driven Sites  with Dreamweaver

list.php: Add Text “update” to 4th Column

Page 43: Creating Dynamic Database-Driven Sites  with Dreamweaver

Go to Detail Page

Highlight the text “update”, then choose to “Go to Detail Page” (in Server Behaviors)

Be sure that “ID_people” data will be passed as a URL parameter.

Page 44: Creating Dynamic Database-Driven Sites  with Dreamweaver

Create “update.php” page

Click on “Bindings” tab, then choose to create a new recordset by clicking on + symbol and selecting “Recordset (Query).

The “filter” must match the data being passed from the previous slide:

Page 45: Creating Dynamic Database-Driven Sites  with Dreamweaver

Record Update Form

Select from menubar…

Insert

Data Objects >

Update Record >

Record Update Form Wizard

Page 46: Creating Dynamic Database-Driven Sites  with Dreamweaver

Complete Dialog Box

Remove from list

Page 47: Creating Dynamic Database-Driven Sites  with Dreamweaver

Modify Form As You Wish

Page 48: Creating Dynamic Database-Driven Sites  with Dreamweaver

Create the Reply page

update_record_reply.htm

Be sure to include a link back to “list.php”

Page 49: Creating Dynamic Database-Driven Sites  with Dreamweaver

Upload and Test the Page

Page 50: Creating Dynamic Database-Driven Sites  with Dreamweaver

Upload and Test the Page

Notice the data appended to the end of the URL

Page 51: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating a User Login Page

Create a form. Then, create a 2 X 2 table in the form as shown below.

In the Property Inspector window…

Title this TextField “email”

Title this TextField “password”

Page 52: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating a User Login PageClick somewhere inside the form,

then select the <form> tag.

In the Action field, enter this page title (we will create the page itself later).

Be sure to choose POST as the method.

The GET method will send the user’s email and password as part of the URL, which is a security risk. Upload the page.

Page 53: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating the “update-account.php” Page

Insert a 2 X 1 table with messages as shown below in each row.

Page 54: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating the “update-account.php” PageIn the Bindings tab, choose to create a new Recordset (Query):

Name the recordset “rsAccount” and select the connection:

Page 55: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating the “update-account.php” PageClick on the “Advanced…” button…

The dialog box changes to give us access to the SQL programming…

Page 56: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating the “update-account.php” PageEnter the following SQL code and add the variables – varEmail and varPassword - as shown, test the code for errors, then click “OK”:

Page 57: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating the “update-account.php” Page1. Click somewhere in the first row, then click on the <tr> tag to choose that row. This selects the row as a “region”:

2. With this region selected, go to the Server Behaviors and choose:Show Region > Show Region If Recordset is Empty.

3. Choose the ‘rsAccount’ RecordSet, and click OK:

Page 58: Creating Dynamic Database-Driven Sites  with Dreamweaver

Creating the “update-account.php” Page

Repeat the steps on the previous slide, except:Select the second rowChoose to “Show Region If RecordSet Is Not Empty

Upload the page.

Page 59: Creating Dynamic Database-Driven Sites  with Dreamweaver

Test the Log-In Page

Page 60: Creating Dynamic Database-Driven Sites  with Dreamweaver

Test the Log-In PageIf you log-in correctly, you should see this result…

If you log-in incorrectly, you should see this result…

Page 61: Creating Dynamic Database-Driven Sites  with Dreamweaver

Use the “Record Update Form Wizard” to add an update form to the second table row

Select from menubar…

Insert

Data Objects >

Update Record >

Record Update Form Wizard

Upload the page and test the site.

Page 62: Creating Dynamic Database-Driven Sites  with Dreamweaver

Maintaining “State” of a UserTwo Approaches

• Passing data via the URL from page to page– Exactly what we have been doing so far– Drawbacks

• Users can bookmark specific pages without logging in

• Savvy users can access accounts other than their own

• Creating a session variable– User’s browser must be set to allow “cookies”

Page 63: Creating Dynamic Database-Driven Sites  with Dreamweaver

Session Variable

• A type of cookie

• Stores a particular piece of information temporarily on the client’s computer– The variable is deleted when the browser is

closed, or when there is inactivity for a set period of time.

• How and where to declare this variable?

Page 64: Creating Dynamic Database-Driven Sites  with Dreamweaver

Where to Set a Session Variable

• Needs to be set after a verified log-in has occurred

• Recommendation– Add this variable in the “Show Region”

behavior

Page 65: Creating Dynamic Database-Driven Sites  with Dreamweaver

1. Click here to highlight the “Show Region” behavior associated with a successful log-in.

2. Click here to view the code.

Page 66: Creating Dynamic Database-Driven Sites  with Dreamweaver

We will add the code to create the session variable as the first line AFTER the “If-then” statement

ASP Example!

Page 67: Creating Dynamic Database-Driven Sites  with Dreamweaver

<% Session ("People_ID") = rsAccount.Fields.Item("People_ID").Value %>

Name of the record set. Name of the variable we need from the record set.

ASP Example!

Page 68: Creating Dynamic Database-Driven Sites  with Dreamweaver

Using Session Variables

• Create a new .asp page

• In the Bindings tab, create a new record set and use the Session variable as a filter:

Page 69: Creating Dynamic Database-Driven Sites  with Dreamweaver

Other Useful Session Commands

• Setting a time limit (in minutes) for when the Session variable will expire if there is no activity:

• Creating a “Log Out” option that clears all session variables

<% Session.Abandon %>

<% Session.TimeOut = 300 %>

ASP Example!

Page 70: Creating Dynamic Database-Driven Sites  with Dreamweaver

VB Script

ASP Example!

Page 71: Creating Dynamic Database-Driven Sites  with Dreamweaver

In Simple English:

If “ready4feedback” equals “y”, then display

Otherwise, display

Useful VB Script Example

This “If-Then” statement checks the value of a particular field in a recordset and displays an appropriate graphic depending on its value.

<% If (rsIDA_course.Fields.Item("ready4feedback").Value) = "y" Then _ Response.Write("<img src='resources/yes.gif'>") _Else Response.Write("<img src='resources/no.gif'>") %>

ASP Example!

Page 72: Creating Dynamic Database-Driven Sites  with Dreamweaver

Book Recommendations for Learning More

Page 73: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 74: Creating Dynamic Database-Driven Sites  with Dreamweaver
Page 75: Creating Dynamic Database-Driven Sites  with Dreamweaver

References• Bardzell, J., Flynn, B. (2007). Adobe Dreamweaver CS3

with ASP, ColdFusion, and PHP: Training from the Source. Adobe Press.

• Lowery, J. W. (2007). Dreamweaver CS3 Bible. Indianapolis, IN: Wiley Publishing.

• Meloni, J., & Telles, M. (2008). PHP 6 Fast & Easy Web Development. Boston: Course Technology.

• Mitchell, S., & Atkinson, J. (2000). Teach yourself Active Server Pages 3.0 in 21 days. Indianapolis, IN: SAMS.

• Ray, J. (2003). Teaching yourself Dreamweaver MX Application Development in 21 days. Indianapolis, IN: SAMS.


Recommended