DreamWeaver MySQL Record Insertion PDF Print E-mail

This tutorial will set up a dynamic web page in PHP that allows for the insertion of data from a webpage to your database table.

This is the base application from DreamWeaver that will provide data and recordsets for the other applications like User Login, Master-Detail and Dynamic Table displays.

In this tutorial we will be creating a user information dataset so that we can interact with the User Login process later. This will be a "User Registration" page.

  • A Username
  • A Password
  • An E-mail

Record Insertion Wizard

We will be using the Record Insertion Wizard from the Application Control Bar in DreamWeaver. It is the icon that shows a yellow can with a blue "Wizard Hat"

This application will start a wizard that creates a HTML form element with input boxes and table rows.

  • Before you proceed you should design a database table in PHPMyAdmin
  • This table will include "4" fields in a table called "members" those fields are:
    • userid
    • username
    • password
    • email

If you would like the SQL txt file to upload into your database via PHPMyAdmin

Download here: members.sql - For information on how to upload SQL formatted files into your database click here

If you would like to do this manually:

Open up PHPMyAdmin and Create a new table called "members" and give it "4" fields then press GO

PHPMyAdmin Table Creation Screen

Name the fields:

  1. "userid" INT 5(length) auto-increment and make it the "Primary Key"
  2. "username" VARCHAR 12
  3. "password" VARCHAR 10
  4. "email" VARCHAR 30
PHPMyAdmin Table Settings

 

What is going on here: We are setting the names of the fields that will contain our member's information so that they can login to our site. We can use this same process to insert catalog items for display on our pages as well. That would require a different table with item ids, names, descriptions and image locations etc.

What do those attributes mean?

VARCHAR means "Variable Characters" - Letters and Numbers up to 255 characters in length. You could use VARCHAR for a small story too.

INT means "Integer" or a number, we have also set this field to do "auto-increment" that means when a new record is inserted into the table it will take on a number in succession 1, 2, 3, 4, etc. We also set it as the "Primary Key"

Primary Key designates this particular field as the main ID for this record. We can use this Primary Key later on to link to other tables of data. The easiest way to understand this concept is that a customer will have an ID number that can be referenced in a different table for current items this customer has on order. Or shipping methods this customer desires in a different table.

CLICK SAVE

 

 

The Results

Create the record insertion page with DreamWeaver

Now that you've set up a table in your database to receive data, you can connect to your MySQL database with DreamWeaver and use the "Record Insertion Wizard" that creates the record insertion form and HTML input types.

Please make sure that you have a site defined for PHP/MySQL in DreamWeaver as in "Setting up DreamWeaver with MySQL"

Connect to your database :

  1. Open a NEW php page.
  2. Make sure the Databases panel is displayed. We will call this connection inserting
DreamWeaver display with inserting database shown
  1. Click on the expanded views to show the table data in "members"


    Expanded View

This will show the data table you created with PHPMyAdmin.

 

Save the file as insert.php

 

The Record Insertion Form Wizard

Click on the drop down and select "Record Insertion Form Wizard"

Expanded View

The resulting screen:

Insertion Wizard Applet

The dropdown fields in this applet will display the Connection, Table, and form fields of your Table "members" in your database

Type in "whoswho.php" in the "After Inserting, go to: field" --- This page will created later using the "Repeated Region" process to display the new members in your site's database. It will be created in that Tutorial.

CLICK OK

Resulting page:

New Insert Form Page

As you can see, DreamWeaver has created a Form element on the page with the criteria we set as default in the Record Insertion Form Wizard. This page can be uploaded to your site and take input and feed it to your members table in your database. It has created the php code neccessary to connect to the database and format the information from the form and place into the appropriate field designations you set up in PHPMyAdmin

However, there are some things that you need to take into consideration before you upload this file.

  • There is no need to include the field for "Userid" you may delete the row. Why? If you remember the userid field is auto-increment and it is being set by MySQL and not the new member. We don't want members creating their own ID numbers. We could have done this before the form is created by selecting it in the wizard and then pressing the "-" (minus) sign to remove it from the form fields in the wizard.

  • There is a new folder in your site definition file. It is called "Connections" it contains a file called "inserting.php" - this file is the MySQL connection file that the insert.php page calls in order to connect to your database. If you look at "inserting.php" you'll see a connection string written in PHP that has your database name, login and password. This folder and it's contents must be uploaded at the same time you upload "insert.php" for that file is dependant on the in order for this whole process to work. You will see many pages with this connection string at the top as you do more DreamWeaver tutorials from this site.

  • You have not created a "whoswho.php" page for this form to switch over to in a browser after a member submits information. You must create it next by selecting --->

Creating Dynamic Tables that display records in your database.

Last Updated on Sunday, 03 June 2007 02:01