Professional Documents
Culture Documents
On the CD
Tutorial files:
Survey.php, register.
php. thankyou.php,
loginfailed.php & more!
Tutorial objective
Create a simple survey application
using the MX Kollection extensions
Time required
One hour
Skill level
DREAMWEAVER COMES BUNDLED with a number of
01 Create a database
Our questions and the responses made by the users need
to be stored in a MySQL database. Launch the MySQL
commandline and log into your database server. Type:
CREATE DATABASE dbSurveys; USE dbSurveyts; to create a
database and switch to it.
04 The questions
The next table needs to hold all of the questions. There
might be many surveys of questions here and we know
which questions belong to which survey because the
surveyID field of the relevant survey is inserted. The fields
for this table are questionID, surveyID, and questionText.
05 The answers
Finally, we create a table to store the answers that people
type in. This table stores the userID (so we know who
answered the question) the questionID (so we know
which question they were answering) and the text that
they entered into the form.
06 Add a survey
We need some surveys to work with, so insert into
tblSurveys a survey, then enter three or four questions
using that surveyID into tblQuestions. The complete SQL
script that I have used is available on your cover CD,
complete with question data.
11 Registering users
Create a new PHP page and save it as register.php.
Open the Server Behaviors Panel and select MX
Kollection>User Login>User Registration Wizard. In the
Wizard that opens click Change Login Settings. In the
dialog that opens, the tab Options can be left as default.
15 Validation rules
The next step of the wizard allows you to set the form
validation rules. We want to ensure that users complete
all fields of the registration form so select each field and
check the required checkbox. For the email address you
can specify that it is in the correct format.
Technique
Edit the
default CSS
The user registration and login wizards
insert forms on your pages, but you
can edit these to suit your sites design
20 Restricting access
1: Editable elements
Select the element in Design View and then
look at the style drop-down in the Inspector.
The name of the CSS applied to this element
will be displayed there so that you can find
it in the CSS files attached by the Extension.
In detail
To create a new table you need to use a CREATE SQL statement and
specify each field and its datatype
surveyID INT,
questionText TEXT);
Finally, we need the table in which we store the
answers users input - tblAnswers. This needs to contain the
userID of the person answering, the questioned of the
question they are answering and then the text that they
have input as the answer to the question.
CREATE TABLE tblAnswers (
answerID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
userID INT,
questionID INT, questionAnswer TEXT);
Error message
The code inserted includes error
messages that display if the user
does not complete the form
Server selection
With MX Kollection the Server
Behaviors are available from the
Server Behaviors Panel
Wizard registration
The registration form was inserted
by the MX Kollection Wizard, which
adds HTML and server-side code
Filing system
Quick linking
Calling code
When creating basic HTML pages in
Dreamweaver I still style my text the oldfashioned way: I select the text and then
format it via the Properties window. I notice
that this creates a whole host of styles in the
Style list, all with the name style followed by
a number. I would like to give the styles a
more appropriate name, so is there an easy
way to do that?
Expert advice
Instant JavaScript
Dream layout
I use Dreamweaver, and rarely use anything but
the Design View. The thing is, I do
not particularly like the setup of the work area
as I do not have enough space to see what I am
designing. Can I customise the workspace to
suit my needs?
The workspace in Dreamweaver has a
number of viewing options. Design View
is the most popular, but it can become
overcrowded, leading to confusion. Before
you think of rearranging your workspace
try the Zoom option, which resides in the
bottom right corner. The Fit All and Fit
Width commands are especially useful
as they can give you an instant view of
the whole page you are working on. To
actually move the components of the
workspace involves a trip to the Window
menu. Here you will find Workspace
Its easy to manipulate your working area so that you can see what
youre designing; just head to the Workspace Layout option
I have been using Dreamweaver to create sites ever since I delved into
the world of web design. However, I have only ever used the program to
create and design static sites, and now Id like to start adding dynamic
elements. I know a database is needed, so I contacted my web hosting
company who told me how to set up a database with my account which
uses MySQL and PHP. How do I add the information to a page?
include your FTP details so you can preview the updates you make
to the page. Then you will have to create a new page using the PHP
extension and set the connection to your database server.