tarnfeld
tarnfeld

Reputation: 26556

How to use HTTP Authentication with PHP and then run the entered data against a database?

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 :/

Upvotes: 2

Views: 2280

Answers (1)

Pascal MARTIN
Pascal MARTIN

Reputation: 401152

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

Upvotes: 4

Related Questions