Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-08-2004, 04:30 PM   PM User | #1
gismo
New Coder

 
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
gismo is an unknown quantity at this point
Restricting Access

Hi All,

I have two users on my site a student and a teacher, i want the system to be able to recognise whether a student or a teacher has logged on and then allow the teacher to access the teacher area, while dissallowing the student to access it. Any suggestions??

Thanks,
Gismo
gismo is offline   Reply With Quote
Old 05-08-2004, 06:17 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
What web server are you running?

If your running Apache, you can use .htaccess to do what your going for.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 05-09-2004, 12:59 PM   PM User | #3
gismo
New Coder

 
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
gismo is an unknown quantity at this point
Thanks OracleGuy. Do you much about .htaccess as i have tried this but cant seem to get it working. Here is the code that i am using. I would really appreciate any suggestions.
.htpasswd file:
Gismoassword

.htaccess file:
AuthUserFile /c:/apache/.htpasswd
AuthGroupFile /dev/null
AuthName Teacher Area
AuthType Basic

require user Gismo

Thanks,
Gismo
gismo is offline   Reply With Quote
Old 05-10-2004, 07:31 AM   PM User | #4
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
First off, are you making sure you use MD5 encryption on the password? There is a program that comes with apache that can do it through the command line. Or you can make a small .php page and put:

PHP Code:
<? echo md5("Password"?>
And it will yeild the MD5 version of your password to put in the .htpasswd file. Remember since MD5 is a case-sensitive encryption, your password is then thus case-sensitive.

Additionally, from the code you posted I assume your running apache on a windows OS?
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 05-10-2004, 11:02 AM   PM User | #5
gismo
New Coder

 
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
gismo is an unknown quantity at this point
Hi,

Yes i am running Apache on Windows XP. The .php file do a need to save it in the same directory as the htaccess file and do i need to give it a particular name?

Thank You,
Gismo
gismo is offline   Reply With Quote
Old 05-10-2004, 01:33 PM   PM User | #6
bcarl314
Mega-ultimate member


 
Join Date: Jun 2002
Location: Winona, MN - The land of 10,000 lakes
Posts: 1,855
Thanks: 1
Thanked 45 Times in 42 Posts
bcarl314 will become famous soon enough
Quote:
Originally Posted by gismo
Thanks OracleGuy. Do you much about .htaccess as i have tried this but cant seem to get it working. Here is the code that i am using. I would really appreciate any suggestions.
.htpasswd file:
Gismoassword

.htaccess file:
AuthUserFile /c:/apache/.htpasswd
AuthGroupFile /dev/null
AuthName Teacher Area
AuthType Basic

require user Gismo

Thanks,
Gismo
Also, I doubt the "/c:/apache/.htpasswd" line will work.

Starting a directory path with a "/" is a Unix thing (*nix). Try removing the beginning "/" on that line.

Also, you're using "/dev/null" for your group file. Again in a *nix format. Try dropping the line or replacing it with a valid window path.

Hope this helps
bcarl314 is offline   Reply With Quote
Old 05-10-2004, 07:00 PM   PM User | #7
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by gismo
Hi,

Yes i am running Apache on Windows XP. The .php file do a need to save it in the same directory as the htaccess file and do i need to give it a particular name?

Thank You,
Gismo
No, just put it in the same folder as your website. Then visit the page in your browser and PHP is generated the encrypted version of your password. The page name doesn't matter.

Once you do this, you can copy the encrypted version of the password into your .htaccess file.

If you've done what bcarl and I have said and it still doesn't work, you might need to change the file to something like ht.access and change your Apache config file. Because Windows sometimes has issues with dealing file filenames that have just an extension.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:02 PM.


Advertisement
Log in to turn off these ads.