Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
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.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97212 Viewers
61 Video lessons · 84503 Viewers
71 Video lessons · 68706 Viewers
56 Video lessons · 101188 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.