views:

40

answers:

1

Creating simple php login scripts is easy, with simple one table mysql integration. I was wondering how i could you the rather snazzy HTTP Authentication that is available in HT Access and PHP, but the users are checked against a mysql database?

I am sure this is possible, but i have no idea how :/

+1  A: 

The authentication data (at least if using Basic mode) should be available in $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] (see $_SERVER) -- which means you "just" have to use those to check with your database.

Here's an article about that, for instance : HTTP Basic and Digest authentication with PHP

Pascal MARTIN
So i would run the `isset($_SERVER['PHP_AUTH_USER'])` and then check the sent http data against my database, then return this `header('HTTP/1.0 401 Unauthorized');` if they are not allowed, or this (i dont know what to do) if they are :)
tarnfeld
The "this I don't know what to do", you are the only one who can know : it's what users who have entered their credentials should be able to do ;-)
Pascal MARTIN
Ah is see, so if they are ok - then there is no need to pass over any HTTP header? :) cool!
tarnfeld