Skip to main content
Participant
August 5, 2011
Question

Login Users to Different Pages

  • August 5, 2011
  • 1 reply
  • 1029 views

I have a mySQL DB with about 10 usernames, passwords, and ids. I have the DB connected to a user login, however DW's user login only gives you the ability to have all users be directed to the same page. These 10 users all need to be redirected to their own secure web pages. I have read on similar threads that I should add a new field to mySQL DB to add the respecive urls I want to send the users to. That I can do. However, what do I need to do as far as coding goes to send these users to their own pages?  I haven't done much coding before so I am really just looking for either a relatively simple explanation, what the coding would be, a good book for learning things like this, a tutorial, or anything else that can point me in the right direction. Any help would be much appreciated. Thanks!

This topic has been closed for replies.

1 reply

Community Expert
August 6, 2011

If the pages that these users will be redirected to is the same (eg: facebook) where photos, feed, etc. are in the same position you only need to direct them to the same page and based on their login details pull the proper information out of the database.

To further look at this you need to think about:

-Will users see the same page with different information?

-If anything is different, what is it?

-Do users fall into groups instead (eg: admin, contributor, etc)?

Then depending on the setup and your willingness/desire/timeframe to learn would you consider a pre-built option (eg: CMS) to accomplish your goals?

David has a tutorial on the Adobe website briefly going over login scripts that you might want to read over as well.

http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt2.html

dshmedAuthor
Participant
August 6, 2011

Thanks for the response. The user's landing pages are all very different. Each page is designed with the client's logo and color scheme. For example Cisco Systems might have their logo with blue and white backgrounds and fonts. They are pages where our clients will be able to download excel and powerpoint reports for projects that were created exclusively for them. They are structurally quite different in that we serve a broad range of services to our clients. Some will have only one page while others might have many. The landing pages have already been created completely, but I just can't seem to find a way to redirect the clients to their respective pages when they log in. The landing pages have been created like so:

Client #1: mydomain.com/portal1_home.php

Client #2: mydomain.com/portal2_home.php

etc.

One thing I tried was to redirect them with this php code i received from another post on this topic when I asked in another category. This worked great where each client gets redirected to their own page, however the pages aren't restricted so if someone were to guess at what another client's portal url might be they would be able to do so.

<?php

if (array_key_exists('passSubmit' , $_POST)) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if (($username == "Client1") && ($password == "client123"))
{
header('Location: http://www.mydomain.com/portal1.php');
}
if (($username == "Client2") && ($password == "client234"))
{
header('Location: http://www.mydomain.com/portal2_home.php');
}
if (($username == "Client3") && ($password == "client345"))
{
header('Location: http://www.mydomain.com/portal3_home.php');
}
else {
$passError = "<p>That is the incorrect password</p>";
}
}
?>

So I guess what I need is a way to restrict these landing pages from unauthorized access from typing in the URL, i.e. the only way to access them is through the login. I apologize if I seem naive in this matter, but I am relativedly new to DW and web design in general. If there's an easy to get this accomplished that would be great, if not I am certainly willing to take the long way and learning it on my own.

Community Expert
August 6, 2011

Thanks for the response. The user's landing pages are all very different. Each page is designed with the client's logo and color scheme. For example Cisco Systems might have their logo with blue and white backgrounds and fonts. They are pages where our clients will be able to download excel and powerpoint reports for projects that were created exclusively for them. They are structurally quite different in that we serve a broad range of services to our clients. Some will have only one page while others might have many. The landing pages have already been created completely, but I just can't seem to find a way to redirect the clients to their respective pages when they log in.

This is a perfect example of why you load dynamic content.  You can load a different CSS file to load a different images folder and then just name all the files the same (eg: styles.css, logo.jpg, index.php).  Then redirect users to pages like:

mydomain.com/portal.php?company=Cisco_Systems

Which in turn you use mod_rewrite by adding the following to a .htaccess file:

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule ^portal/([^/\.]+)/?$ index.php?company=$1
</IfModule>

Which creates the address:

mydomain.com/portal/Cisco_Systems

So your script would point to that address on a successful login.  I still haven't heard anything to convince me that this is easier with separate pages for each company given that once a user logs in you can pull styles and images based on the login.

But once you have that page you can use sessions, cookies or a combination of both.  A good session tutorial to get you started can be found:

http://www.tizag.com/phpT/phpsessions.php

Basically on your single login page you include a file that verifies an active session or cookie.  Upon verification of the session you allow the client to view the information of their respective company and the projects associated with those companies.  This brings to question whether or not you have a data structure setup so that you know how to assign which projects to which company when they open their page.

One other thing to consider if you have not already is learning about robots.txt files to learn how to prevent search engines from indexing files/folders on your server and also to consider saving the files above the web root which is typically a /public_html folder just to keep them private and only allow access from your script.