Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    What web server are you running?

    If your running Apache, you can use .htaccess to do what your going for.
    OracleGuy

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    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
    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

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •