Viewers: in countries Watching now:
An important but little-understood concept in dynamic web development is that of role-based logins, which allow different types of users to access different parts of the site. In this course Adobe Certified Expert Candyce Mairs shows how to use Dreamweaver's features to create role-based logins, restrict page access, build an administrator area, and test everything to make sure it works. Plus, see how to set up a development environment and work with a database from within Dreamweaver. Along the way, build your skills in areas like working with PHP, adding form validation, using server behaviors, and much more.
We are now going to take a look at adding the log in functionality for our Scoopity-U website. What I have at this point is the login page open. This log in page does have two spry fields on it. In case yours does not within the chapter six start files there is a log in spry completed file you can use as a base and copy that as login.php. If you did not get the log in spry piece completed.
So here is our log in form. Now in order to add functionality to this form. First of all, using spry. We're making sure that the user has to insert information into the form. So let's preview that and let's try that one more time, because it sent me to the log in spry page instead. Here we go. Log in PHP. So I have two fields on this form, Email and Password.
If I do not enter anything into either field, you can see this is what happens. And if I don't enter correct email information into this area it gives me the message please enter a valid email address. So, what I can do is I've already registered for the website so my email address is in the log in table. And when I registered, I put PWD inside here.
I will click Login, and I'm logged in, or not. We have no idea. We haven't added any funtionality to this page. And the idea is if I click Login and I can't login, I should be sent to a different page otherwise it's very confusing. So let's go out and create a page for users who cannot login. I'm going to open up template.php. This is just a basic page, we can save.
And I'm going to save it as Login-now. The reason I'm adding the dash is it will put this page in alphabetical order with the rest of them. If I said no login, this page would go way down below. So it just helps me keep these pages together. Now, my naming convention for the rest of the pages is using camel casing, in other words, every word but the first one is capitalized.
So I'll use that same naming convention here. Click Save, and up at the top here I'm going to say, Your Login Did Not Work. And down below I will say, If you do not have an account please register to use this area. Use the members' area.
And I'll register, I'll double-click that word. There we go. And we will create a link to the register page here. So click on Point To File, this little icon here in Dreamweaver, drag out to the Register Page and, I, now have a hyperlink. I'll save this page and there's where we're going to send them if it doesn't work. Now let's add some functionality besides form field validation.
And the way we do that is select the button what you need to do is tell Dreamweaver what needs to happen in order to trigger this behavior to run. Specifically the login user server behavior so I will select the Submit button when the user clicks that that's when we want this to happen. I will now go out to the server behaviors panel. And just in case yours is not open, you can always get to it through the Window menu.
I'm going to hit the plus sign. Go down to User Authentication, and say Login user. Now this looks complicated but it's really divided up into multiple sections, so it's not too hard. The first thing we need to do is fill in the form name. Well, we didn't name this form anything specific, down in this area, you can see our form is named Form one. So that's where that is coming from. The user name field is our email field. And the password field is password.
Dreamweaver populated these three correctly for us. What we need to do is tell Dreamweaver which database we're going to authenticate against. Which table to use within that area and which columns. So our Username column will be username. Password will be pwd. If the login succeeds we're going to send them to the members' home page. So this is the home page for our members.
If the login did not work, we're going to browse out and send them to the login no page. So, if it succeeds we should end up on members home. If it doesn't, we should end up in the login no page. And we're going to restrict access based on user name and password, and access level. We're going to get the access level fromINAUDIBLE within this area.
We will click OK, and there we are. Now, there's our login form. Within our login user, if we want to change anything we click this login user area. Now I'm only going to log in people based on username and password for now. We haven't set up the administrative area so we don't have to restrict this to any particular access level. So I am going to switch that back to user name and password and click OK. Now what it should do is actually function for us. So let's go out to preview this in the browser.
I will plug in my email address and make sure you're using one that you are actually registered for. Notice our password field here hasn't been change to a password. Another reason we want to test these, so we can modify that when we go back. I'll click Login. You can see I was taken to the members area page without a problem. So my login worked. What if I have a login issue, and I'll put my name in. But I'll just put a bad password.
And it's not my actual password. I want to make sure that it prevents me from seeing the members' area. So I will click Login, and it did. So our login piece is set up. Let's fix our password field. And within this password field area. We have some information in here. And if I get into the text field. Here's our information. I'm going to go into Split View to make this a little bit easier, so I'll select the spry text field, and the reason this is not set up as a password is because if I click inside this field for password you can see that this is not a password here.
We also have two labels for our password. One is set up here, here is the other one. So we don't need this top one here. I'll get rid of this one. So I'm just cleaning up some code that occurded. And this is actually the label for password. This an accessibility issue. And let me move up to show you that. So we have our spry text field right here. Within our text field, we have a label, and this label in other words, this word, password is the label for this specific form field.
This tells a screen reader, that this is the word that should be read to describe this form field. So we'll just clean that up a little bit. Some how. There was some extra coating within that area. Under ID, I will also set it to just password because we ended up with an additional label within this area, Dreamweaver added the ID of pwd2 because you cannot have two ID's within the same page. So there we are, we are all set and our login should be working correctly.
And we've cleaned up our password area now let me just go double check that password area and make sure if I enter something it's a password perfect our login form is all set including functionality. Now what we need to do is go out and make sure that we restrict access to our pages. Because right now anybody can go out to Member Home. So there's one last piece we need to set up. And you can see this page is not fully set up within out site.
So we'll move out into the Member area and take a look at those pages and get those all fixed. So we have a complete login process.
There are currently no FAQs about Dynamic Dreamweaver Websites: Creating Login Areas.
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.