New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

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

Updating the database data

From: Dynamic Dreamweaver Websites: Creating Login Areas

Video: Updating the database data

Our Administrative Area for updating a user and that user's information is almost complete. At this point, we have our Admin User List. This is a listing of all of the users or members inside our website. You can see some of those members are missing some information. But we have our table printing out all of our members. We also have the User ID for each member as a hyperlink.

Updating the database data

Our Administrative Area for updating a user and that user's information is almost complete. At this point, we have our Admin User List. This is a listing of all of the users or members inside our website. You can see some of those members are missing some information. But we have our table printing out all of our members. We also have the User ID for each member as a hyperlink.

It is passing the query string information. So, if I click a particular member, I'll use John, its passing the User ID to the User Update page. We are using that User ID information to query the database, our login table for that user's information, and we now have that information populating our form. There is one minor issue occurring within our form. And that is our role is actually adding the User ID within this area, not showing their specific role.

The reason is because when we created this information for this menu, it's not quite correct information. Now, I don't like to show you everything working perfectly. I'd like to show you some of these issues that can occur so you'll learn how to go back and modify information as well. So when you're on your own, it makes sense and you know what to do when a problem occurs. So, let's go back out to that particular form, which is this one here, the Admin User Update page.

Let's fix this role menu before we plan the Update button. In our Role Area, if I select that menu and click the Dynamic button, you'll see these are static options, so these are not coming from our database. The information is coming from our record set out of the database, but the values I am using for both this area, the information passed in the form and what the user sees, is being set up based on the User ID.

Which is why we're seeing that number. What I want to do is change this to role. So, I will set these up to populate based on the user's role in the database, not their ID. If I click OK, I'll go back out to the browser. I'll go back to the User List, click John one more time, and this time he's being shown as a guest. And let me Refresh this page just to make sure.

We still have our tour ID showing up in here, so our page has not been refreshed. Notice I have this little asterisk here. That means I haven't saved the new page, so I'll go back to User List Preview, this in the browser. Once again, having to login, click the Login button. Here is John's User ID. I will select that. It's showing him as a guest, and we have gotten rid of our tour ID from this listing.

Now, the reason that this is showing three pieces is this one is coming from the database. These two are static options. They're not in the database. So, I need to make a decision. Do I want ot have the static options listed in additon to his present role, or how do I want to set that up? And I'm just going to leave this as is for now because I should be able to switch to the Admin User and click Update User Details. We will insert him as an Admin User from that point on. So, it's up to you if you want to get rid of these top two static options. If you wanted to, you would go out to the menu on the Update page, click the Dynamic button, and these are the two that you're seeing in addition to a listing of what the present role is.

Now, this form could be set up a little bit different. We could have the role say, Present Role, and only show the database data. And we could put another menu underneath this one saying, Updated Role, and we could allow the admin to chose admin or guest in that second menu. I am doing this all within a single menu. So, as soon as they click on a User ID, it will show to our admin folks what their present role is and it will give them the option to change to either one of these all within the same menu.

It makes it a little bit simpler, our admin can do things a little faster. So, we will have three listings in there. The first one that shows will be what they are in the database right now, and then they can choose which of these additional options they want to change to. I don't think that will be too confusing since we're only having a limited number of admin people working in this form anyway. So, there is our role corrected, listing their present role in the database and giving our admin the choice to switch them to either guest or admin depending upon what their present role is. Now, we need to add the update record piece.

So, I want them to be able to change that data. And when they click this Update User Details button, it's going to change the data in the database to that new information in the form. In order to do that, I need to go out to the Server Behaviors panel. This can be accessed within the Window menu, if it's not open. You can see we have quite a few server behaviors listed. As we've added these dynamic features within Dreamweaver, Dreamweaver has added them here for us so we don't need to be concerned about that.

That is what's creating what we've done so far. What I want to do is add to it, so I'll hit the Plus sign and I'm going to say Update Record. Now, within this interface, we have our form, and I don't have my form named properly. Notice down in the Tag Selector it says Form 1. I could have it say Update Form. I'm not going to be concerned about that right now because it does not affect our functionality at this point.

So, that is the only form we have on this page, so that's why it's populated here. Our connection we want is this Con Login connection, but the table we're going to be working in is the Login Table. And as soon as we choose Login, what Dreamweaver is going to do is try and match up the columns in our database, which is this first listing, with each of the fields within our database. So, it says form dot. These are the form field names.

But notice our User ID is not being used right now. In order to update a single user, we need to tell the database which user we want to update. And our form does not have that information in it presently, which is why our User ID says it's not being used. We need to use that. So, I'm going to Cancel out of this piece. We need a way to add the User ID to this form so the user cannot modify it.

But the Update Record Server Behavior will have access to that information. So, we can send the database which user to update. In order to add that piece, what I'm going to do is add a hidden form field. Now, this can be plugged into anywhere on the form, it does not have to be on the end. I'm just putting it here to make it easy for you to see where this is located. The hidden form field is the third icon. It says Hidden Field on it in the Forms tab of the Insert bar. So, I'm going to click that Hidden Field icon.

It adds a hidden field wherever my cursor is, and that hidden field is going to become our User ID information, telling the database which user to update. So, User ID will be the name of it. Our value is going to come from the database. So, our record set that we created in the Bindings panel has a User ID being pulled out, and this is why we wanted that. So, I'll click Bind to Dynamic Source.

We're going to set our Hidden Form field name to User ID, the value is going to be whatever the User ID is for the user that's shown. I will click OK, and Dreamweaver populated that information for PHP to figure out which User ID it is. Let's go out to Save this. And I need to go back to my Admin User List. So, I will hit the Back button here, and we'll start from the beginning.

User ID is number 3. We now have populated John's information within this area. Also, on this page is a Hidden Form field. If I go into View Page Source, there is a Hidden one right down here, this must be within our Form tag, and the name is User ID. Notice our value is set to 3. That's because John, who is showing in our form, has User ID of 3. So, that's all being done for us.

Now, we can add the Update Record Server Behavior and have access to that User ID. So, I will double-click Update User Details button one more time. We'll go out to our Server Behavior panel, click the Plus sign, say Update Record. You can see this slick a little bit different because it's the country's table, we'll switch that to Login. Now, Dreamweaver understands our User ID is coming from the form User ID Value. After updating, we will send them back to the Admin User List page where they should be able to see the new information inserted into the database. So, that is our Update Record Server Behavior all set up within our Update form.

Show transcript

This video is part of

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

43 video lessons · 1557 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

Are you sure you want to delete this note?

No

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.