Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We need to add the Restrict Access To Page server behavior to our administrative interface. And when we do that we want to make sure only admin users in the admin role in our database have access to these pages. And right now we just have four pages so it's fairly easy to do this. I'm going to start at the Admin Home page and in our Server Behaviors panel I'm going to restrict access to the page. Now I don't have to be in any specific location on the page. Unlike our Insert new record or our other Server Behaviors that we've attached specifically to the button on a form.
This one is immediately going to test for that log in as a admin. So we don't have to specify any particular area of the page. I will click Server Behaviors. Go down to User Authentication, and I'm going to say Restrict Access To Page. Now within this area, I'm not just going to restrict to user name and password. But I'm also going to restrict their access level. So I'm going to check the second option for our admin area. Now we don't have any levels set up in here so I'm going to click the Define button to set those up and our name is going to be admin. These are the roles in the database we're going to allow. The other role will be a guest.
Once you type it in click the plus sign and you can see we now have two roles available. Once I click Okay, I now have them listed in here. So you can add more than just two. We just need two for this particular site. So the level of access that connects us this page is only admin. If access is denied, we will send them to the Login page.
So if they can't login and access this page, we'll send them here to login again. Now we may want to set up another page that says only administrations can access this page, or whatever you want to do. I'm just using Log In for this course. So I will click Okay. Now you've selected a security method. Either the Login page does not have this, or no user log has been accessed.
So in other words when I have people logging in, they aren't logging in based on a particular user. So let's check this out. I will click Okay. Notice we have Restrict Access to page Admin. Now, we're sending them to the Login page to test that. So let's go down to the Login page. This is what Dreamweaver was trying to warn you of. In our log in area, if we select that in our log in user. Notice we don't have admin.
So let's double check that. So here we are. We have this all set up and restrict access based on user name and password. This is why we're getting that message. So what we need to do is tell Dreamweaver within its security area when they log in, test their access level. We don't have that defined if we're using this top button. So we need to put into our programming where to get that level, and that's what that message was all about. So I'm changing my Login page for everybody to test their level. Now we can Save all of this.
If I go to Admin Home I'll preview it in the browser. If I'm not logged in, I will put my name in here. I'll type it in and lets see what happens. I got to the members area. Now can I get to the admin home area? This page here. So instead of Members Home, I will go to Admin Home, notice I can't. I registered on the website, I am only a guest level access, so I know I'm being blocked.
Now I could go out and check the database. In order to fully test this page, I will look at our log in area, view the data, I am in here another time as Admin. This time, my email address is uniquevacations, password candice. So let me go out and test that one So, Candace@uniquevacations.com.
Password of Candace. I go to the member area. So, if I go back out to this, my role is admin. I should be able to get to the admin area from this page. So, we'll try that one more time. Notice I'm in Admin Home. Let me Close all of these up. If you keep your browser windows open, sometimes it can get confusing when you're trying to test.
So make sure whatever browser you're in, close all of your windows. So we'll try this one more time. Now what should happen, is this Administrative Area I should be led to the log in page. Now our Administrative Area does not seem to be working correctly, and it's because of a very minor issue that I want to point out to you. And what we have done is set up Admin Home, to Insert a New User, and in our user insert they can be added as guest or admin.
This works with the Insert Record and Check New Username area. So that works just fine. But when I go to log in. If I try and log in as admin. It is not working. I'm getting to the Members Area page. Well technically speaking, this is working exactly how we specified this. And this is what can happen if you already have a log in set up. And you later decide to add an Administrative Area. If I want to show you think piece on the Login dot php page. If I double-click the Login button and I get the Login User, Server Behavior from this form and I double-click that piece here is what's happening. These pages are doing exactly what we told them to do. They are logging in the user and sending them to members home. No matter what page they requested initially, what I need to do is check that check box.
What that does is if I'm checking or trying to access another page not Member's Home. It's going to send me to that one instead. A small check box that we did not talk about previously. And I'll click Okay. I will go ahead and Save this page. Let's go back, and I will try and log in. My browser window is closed. So here's my log in, I tried to access Admin Home, you can see it says access check.
Now when I log in, as Uniquevacations.com, set up my password of "candice" and click Login. Instead of always going to Members Home, I should be redirected to wherever I asked for, which should be Admin Home. Let's test it out. And there we are. So our Server Behavior, our Restrict Access to Page, was working correctly.
So, back on our Login page let me just review that in our log in new user this Login User Server Behavior I double click. You want to check go to previous URL if it exist. In other words, if the user was asking for a page other than Member's Home, make sure you send them to the page they were asking for. If they were just trying to get to the Member's Area, they will end up on Member's Home. This covers our admin piece for our administrative users. And we also change the access level for logging in, adding a level from the role area within our website.
So we fine tuned our member log in when we added our administrative login. So now the task is to go out and to test all of this in every way, shape or form. In other words add as a log in as a guest, that's incorrect. Add a log in as an actual person, that's correct. Request another page and make sure you're redirected to that page. Test this Administrative Area much more extensively than I've shown you here because the basic functionality for our admin area is set up.
Now our Admin user insert, has Insert Record and Check New User name, but it does not have a test for access level. So if I go out to Admin Home, restrict access to page Admin. So let's finish this piece up. User Admin insert, I want to restrict access to page on this page as well this will be user name password and access level we select Admin.
If access is denied we will take them to the Login page. Click Okay and I'm going to do this for the two remaining Admin pages that we have set up right now. So Admin User List > Restrict Access To Page. Add the access level they must be admin and if they can't log in here we will send them to a Login page. And our last page to add this to is our Update User piece. So I will add this Server Behavior as well, Add Access Level, choose Admin Access Only, and browse out to Login.
Now as I mentioned earlier If I was going to add a bunch of additional pages to admin. What I would do is create a template for the Administrative Area and add this Restrict Access to Page to it so I don't have to do this on every page. I can use that template for Admin as a Home page and it will already have the Server Behavior attached to it. There we are save this and now it's a matter of testing all of this functionality.
I'll do a quick test of these pages. You can see it's making me log in, tested that one out, good, and this last piece, perfect. Now users have to be logged in as Admin in order to access these pages. Now what we have left is building the Update User. So we want to be able to change your user from whatever information they have into new information within the Administrative Area of our Scuba2u Website.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97283 Viewers
61 Video lessons · 84555 Viewers
71 Video lessons · 68756 Viewers
56 Video lessons · 101245 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.