Page 1 of 1

Is there a way to have a login authorisation via IIS 7?

Posted: Tue Nov 24, 2009 11:35 am
by v2jtb
I am not a programmer and how this all started was that I wanted to have an area on my home website that you can log in and out. I have had a real learning curve when it has come to the installation of PHP, MYSQL, IIS 7 , Fast CGI, PEAR, Smarty and phpMyAdmin. Not to mention the configuration of the above software and different versions, it has been a nightmare but real enjoyable when you see your PHPinfo file working.
I have bought quite a few books including “PHP and MySQL Web Development (4th Edition) (Developers Library) by Laura Thomson” which is really good.
The book has exactly what I want with regards to a login (authorisation :banghead: ) scripts but it uses apache .htaccess files and I am assuming as I use IIS 7 (Vista Ultimate) this is the reason it will not work. I really don’t want to start trying to install another program.
Every book I have bough seems to use Apache but as my website is hosted by Godady.com and I opted for the windows option as I know windows.
Is there a way to have a login via IIS 7?

Re: Is there a way to have a login authorisation via IIS 7?

Posted: Wed Nov 25, 2009 12:58 pm
by ambivalent

Code: Select all

if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) 
    && $_SERVER['PHP_AUTH_USER'] == 'your_username' && $_SERVER['PHP_AUTH_PW'] == 'your_password'))
{
    header('WWW-Authenticate: Basic realm="Go away"');
    header('Status: 401 Unauthorized');
}
    else
{
    echo 'hello world';
}
 

Re: Is there a way to have a login authorisation via IIS 7?

Posted: Fri Nov 27, 2009 11:17 pm
by Doug G
You should check the godaddy help and faq's for anything specific to godaddy hosting.

Usually you use windows file permissions to control access to sections of a website. If you remove permissions for the user account that IIS uses to handle anonymous web users from a directory or file, IIS will prompt for windows authentication to access the resource. This has the advantage of restricting access to any non-web files in the directory too, so a user can't browse directly to a jpeg, for example.