如何使用HTTP认证与PHP,然后对数据库运行输入的数据?如何使用、数据库、数据、PHP

2023-09-02 00:55:23 作者:越回忆、越心痛

创建简单的PHP登录脚本很容易,用简单的一个表MySQL的集成。我想知道我怎么能对你相当时髦的HTTP认证是在HT Access和PHP可用,但用户核对MySQL数据库?

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

推荐答案

认证数据的(至少如果使用基本模式)的应该是 $可用_ SERVER ['PHP_AUTH_USER '] $ _ SERVER ['PHP_AUTH_PW'] 的(见的 $ _ SERVER )的 - 这意味着你只是要使用这些检查你的数据库。

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.

下面是有关的文章,例如: HTTP与PHP基本和数字认证

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