View Full Version : PHP and SQL login redirects

06-28-2007, 07:42 AM

I used this tutorial: http://www.adesdesign.net/php/tutorials/dreamweaver/secure_login.php

to create a simple login page that redirects fine and is connected to my sql database. however I would like to make it so that I can have 2 different user name and passwords (easy enough up until here) that each redirect to different pages. Is there a tutorial or perhaps some help anyone here can offer me to make this happen? thank you so much any help is greatly appreciated.

06-28-2007, 08:21 AM
To make it flexible you'll want to add a column to your user table that indicates the type of user, and then add code in the login script to read that column and redirect as you like.

06-28-2007, 05:25 PM
Thanks that makes a lot of sense actually. The only problem is I am almost a total newbie with this type of stuff.

so to start with the sql portion of adding in a new column. I clicked add new field and named it "usrtype" however I did not know what option to use from the type drop down menu. is it VARCHAR like username and password is? and what about length/values?

I am not sure how I am going to add in the php code after but I guess I'll deal with this first.

06-28-2007, 05:33 PM
It's your preference, really. Some people like using integers for that kind of stuff... but then you need the legend to know what each number means. (What's does a "6" mean again? bleh) I've seen shop standards use integers, 4-character fields, 8-character fields, 1-character fields...

I personally use enough characters to make the code meaningful. This is usually 4 to 8. For your needs you'd probably do fine with a 4-character column.. "ADMN", "USER", "MOD", are all descriptive enough to me.

And yes, once this is done you're going to have to actually dive into the code, and it's Dreamweaver-generated code too! :eek: Good luck with that.

06-28-2007, 07:26 PM
Ok so I have the sql setup perfectly I believe. So now time to dive into the code as you say.

Dreamweaver actually gives the option to restrict access based on username, password and access level. it then lets me choose my "usrtype" column from my sql server to verify the level. what it is missing however is an option that enables me to select which "access level" redirects to which page. and tips on how I can code that in?

07-04-2007, 10:40 PM
Anyone have any advice at all to help get me kick started on writing the php for this?