Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Connecting to the database

From: Dynamic Dreamweaver Websites: Creating Login Areas

Video: Connecting to the database

The next step after making sure that our database has been installed within MySQL. And we added four more tables, so our Scuba2u database now has five database tables within it. What we need to do is tell PHP where that database is located. And we can set that all up from right within Dreamweaver. I want to make sure that your web server and your database is running. So, you should have the words running, highlighted in green within XAMPP or the Mac side, both your web server and database lights are green. The assumption for every movie from this point on in the course is that both of these are turned on.

Connecting to the database

The next step after making sure that our database has been installed within MySQL. And we added four more tables, so our Scuba2u database now has five database tables within it. What we need to do is tell PHP where that database is located. And we can set that all up from right within Dreamweaver. I want to make sure that your web server and your database is running. So, you should have the words running, highlighted in green within XAMPP or the Mac side, both your web server and database lights are green. The assumption for every movie from this point on in the course is that both of these are turned on.

I won't be reminding you every movie to do so. So, lets go out to Dreamweaver. We have our Scuba2u website set up. What we now need to do is install another folder in our site structure called Connections, but Dreamweaver creates that for us. We're not going to do anything within the Files panel ourselves. How do we set up that connection between PHP and our database? We want to go out to the Database's tab within Dreamweaver.

Now, in case this tab is not open. We can go over to the Window menu and Server Behaviors, Bindings, and Databases, these three tabs are all located together. So, if you open any one of these three using the Window menu, all three are open at the same time. So, the one we want to choose is the Databases panel. Now, if I don't have a page open, you can see that panel's grayed out, my Insert bar is also grayed out. So, you do need to have a PHP page open.

It doesn't matter which page that is. It can even be a brand new one. So, I'm going to create a brand new PHP page. I just clicked that PHP in the green welcome screen. And it activated my panel. Now, you also want to make sure you have three check marks in here. If for some reason, you do not have three, you can use this Refresh button. And if you do not still have the testing server, click the word Testing Server, and it takes you out to your site area.

As long as you have a green check mark within the server's area and you have a green check mark on each of these, you should be able to click Save. And that will refresh this panel, in case the Refresh button was not enough. If you have a red mark right here, what you need to do is go back to the servers area, and make sure your Testing Server is set up. I will click Save. As long as these three have a check mark in front of them, your plus sign will be active.

I will click the plus sign and choose MySQL connection. We are going to let Dreamweaver create this file for us. So, within the connection name, you can really name this anything you want. I'm going to go by the naming convention of putting conn_ in front of it, showing that it is a connection. And I'm going to call this Log In. Now, we're working with everything in the default version.

So, the MySQL server we're working in is local host. Under user name, I did not create a separate user, other than the basic user within MySQL. This is not how you want to run it on the production side. You would certainly want to create a separate user for MySQL and given them specific permissions. We're not going to worry about that in our development environment. So, the basic XAMPP and MAMP installs. Setup the user name as (UNKNOWN) There is no password for the database, and that is the area where you would not want to work as a (UNKNOWN) user and have no password in a production environment.

However, maintain to your servers would setup a separate user for you or for the websites specifically, to be able to access the database. But for now, (UNKNOWN) goes in here, nothing in password. I will click the Select button to choose the database I want to connect to. Once I do this, every database that shows up in your PHP My Admin area is available to you here. So, we're going to choose the Scuba2u database.

I will click OK. And it's always a good idea to test. Now, when you test this. Dreamweaver is reminding you that in a production environment, you don't want to have an open (UNKNOWN) user with no password. So, this is just a reminder, Dreamweaver's trying to protect your database and assist you. I'll say OK. I know there's no password, but I'm going to use it this way, just for development.

I will click OK. We now have our database within the Dreamweaver panel. And if I open up tables, I have five tables listed. Now, if, for some reason, yours is not showing. Click the Refresh button in the top right. But here are our tables. Within the country table, I have two fields. Fields are columns in a database. Within our log in area, I have information about our users that are allowed to log in.

So, I can not only see the exact tables. But I can see the different fields. How many characters they allow. What type of characters they allow. And the other piece is if I right-click the table name, I can view the data within the table. So, here is the information. These are the people who are allowed to log into our website and the role where you have access to. Now, what I mean by role is we're going to be creating in an administrator website area.

And only the admin role will have access to that part of our website. Anybody who's a guest is not allowed into that admin area. We have just setup the connection within Dreamweaver. We now have a connections folder. Inside of that, it is a PHP file with the name of our connection. And if we open that file and take a look at it, you'll see it's just a listing of how to connect to the database.

Now, this is a file I tend to leave alone. So, I'm just going to close it up. But this file and this folder must be on our web server, in order for PHP to connect to the database. Now, if you do end up changing the log in information in your production area, because right now, we are route with no password, you simply open this file and fix that information. And that will take care of your connection.

So, that is how we connect to database using Dreamweaver. PHP can now communicate with the database. And within the Databases tab, we can view our Database information, including the data within the Database.

Show transcript

This video is part of

Image for Dynamic Dreamweaver Websites: Creating Login Areas
Dynamic Dreamweaver Websites: Creating Login Areas

43 video lessons · 1598 viewers

Candyce Mairs
Author

 
Expand all | Collapse all
  1. 1m 32s
    1. Welcome
      1m 32s
  2. 2m 57s
    1. Course overview
      1m 16s
    2. The course environment
      1m 41s
  3. 26m 58s
    1. Static vs. dynamic requests
      4m 8s
    2. Installing XAMPP on a Windows system
      8m 54s
    3. Installing MAMP on a Mac system
      4m 29s
    4. Using admin consoles
      3m 54s
    5. Installing the course files
      5m 33s
  4. 18m 36s
    1. Overview of the Dreamweaver interface
      6m 22s
    2. Setting up the course site
      6m 20s
    3. Previewing pages
      5m 54s
  5. 33m 38s
    1. Creating PHP pages
      5m 45s
    2. Adding PHP code
      5m 44s
    3. Displaying variables
      4m 45s
    4. Commenting your code
      5m 30s
    5. Working with includes
      5m 58s
    6. Building the course templates
      5m 56s
  6. 35m 13s
    1. What is a database?
      5m 2s
    2. Adding database tables
      7m 34s
    3. Connecting to the database
      8m 28s
    4. Getting data from a database: Part one
      8m 25s
    5. Getting data from a database: Part two
      5m 44s
  7. 1h 16m
    1. Planning the login process
      7m 25s
    2. Creating a login form
      7m 45s
    3. Adding form validation: Part one
      9m 22s
    4. Adding form validation: Part two
      1m 37s
    5. Exploring the registration page
      7m 17s
    6. Correcting table fields
      6m 1s
    7. Setting up the login landing page
      4m 1s
    8. Using server behaviors
      3m 36s
    9. Inserting new members
      8m 48s
    10. User authentication
      10m 3s
    11. Restricting access to pages
      5m 17s
    12. Testing the login
      4m 53s
  8. 1h 6m
    1. Admin area overview
      5m 9s
    2. Adding new users
      5m 19s
    3. Restricting access
      12m 25s
    4. Planning the admin update area
      5m 19s
    5. Building the members table listing
      6m 55s
    6. Building the querystring
      9m 14s
    7. Populating the update form
      6m 33s
    8. Updating the database data
      11m 28s
    9. Testing the admin update process
      3m 47s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dynamic Dreamweaver Websites: Creating Login Areas.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.