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.
At this point in our course we have the pages set up to Register and Log in. We have quite a few separate pieces created. Now what we need to do is start adding a functionality. So we're going to move over to our Register.PHP page. As of right now this page does not have any form validation on it. I could convert these text fields to Spry text fields but I purposely kept validation off of this page. So we could focus on adding new users and it just makes it easier when you find out the form.
Do not have to always have everything in perfect in order to make sure that a user can go into our database. Now in the databases area the Login table is were we want to add people for this page. Now if something happens and they cannot register, we should probably have a page for that, especially if they are already registered. So I'm going to go down to the Template page and here is our Registration Form.
And I'm going to say, Registration Form, "Registration Did Not Work." And that's all we're going to put on this page. Actually, let's add register again. Let's setup try and register again. Now if this was a real true functioning page. We would want to set this up a little bit better but I don't want to focus on that piece right now I will save this as Register, Register failed let's just call it that. Now, this isn't really a page name I'd want to use for a user but that a let us know which page it is.
That's why we said registration did not work. Okay. So if they try and get entered into the database and it doesn't work, this is the page we're going to send them to. So how do we do that? I'm going to select the Register button, and we will go over to our Server Behaviors. Dreamweaver Server Behaviors are going to add all of our functionality for us. Now technically what we're doing within this Registration form is adding a new user to our Login table. So we can use the Insert Record server behavior, and when we do we need to tell Dreamweaver what we're going to attach it to.
So the user fills out this form, they click the Register button, that's when we want this to insert the data into the database. So the server behavior is going to be Insert Record. Now here is our form name, so the values from this form it would be best if we set up a specific form name. But since we only have one form it doesn't matter from a functionality stand point. Our connection is going to be our log in connection.
It's the only one we have. We want to insert them into our Login table. Now as soon as I chose that table. What Dreamweaver is going to do here is try and match up all of the fields in our table in the database with the information within this form. Now we have a Username. Username does not get a value. Well, Username is going to become the email. Or should I say, the email address is actually stored as Username.
Since our form field is named email. And our field in the database is called Username. These two do not match up automatically inside of Dreamweaver. If my Form field names are exactly the same, Dreamweaver will automatically know what data to put in what field. So all we have to do, right here, is the Username does get a value, it's just a field not named Username. So I will select that one, and right here I can chose the correct value.
So I will go down, and notice these all say form so the form field called email is going to go into the Username category. Now usually if you are going to insert data into a database table you want to do it in this manner. Where you insert all of the fields Into the database specifically. So Country, Country, Last Name, First Name, role, Password and User ID is simply the row number.
Now after inserting where are we going to send them? Well provided the insert works we want to send them to our Login page. And this is why you want to have these pages already created, so they register. Moves them onto the Login page, where they can use that Login to authenticate against their new record in the database. So let's click Okay. Now there is a bunch of code that's been added to the page.
And we should see Insert Record within our Server Behaviors. I will save this page and let's go out and test it in the browser. Now I'm going to insert myself and I am going to put a correct value in here. I want to put myself correctly into the database. And for my password, I'm just going to use the same name as the form field PWD, all in lowercase just to make it easier. When I click the Register button.
This does ask if I want to remember the password. I'll just ignore that. Notice I am taken out to the Login form. That should mean that I was inserted correctly. So let's go out to our Login table. And let me select that. And then right-click to View Data. And there used to be only four fields within this area, now there are five. And this is one reason why I kept these blank for you, it's easier to tell if your information has been inserted into this area. Now, we are going to build an Administrative section. Where an administrator is able to change somebody from a guest to a an admin. So that is why I wanted to insert my correct information. But our registration form is all set.
Now, let me go out and try and register again. If I go to do that, there is nothing stopping me from doing that. So I'm not actually going to do it. Feel free to try to do it. But you can put your Username or your email address in as many times as you want now. We will add one last piece to this Register button. What we want to do is make sure that there is no other user with that same e-mail address, and it's simple to do this.
I'll select the Server Behaviors, click the plus. I'm going to go down to User Authentication. And I'm going to say, Check New Username. The Username field is the email field. And if it already exists, I'm going to send the user to our Register failed page. Now, I don't have any information on that right now. Specifically saying that your Username has already been taken, we'll just make sure that we get send to that page. So I will Save this, go out to Preview, put my information in once again. Exact same information and it won't let me put the password in by double-clicking in Firefox.
I will go to Register and notice I am sent to the Register failed page. Make sure when you're testing, you test for both pieces. That it failed and it did not. We now have our Registration forms set up very easily thanks to two Server Behaviors built into Dreamweaver.
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.