简单PHP身份验证HTTP
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单PHP身份验证HTTP相关的知识,希望对你有一定的参考价值。
I thought I would share this simple username password php auth script. It leans on HTTP to secure a page.. not bulletproof but quick and painless.
<?php // input user/pass below $username = "INSERT YOUR DESIRED USERNAME HERE"; $password = "INSERT YOUR DESIRED PASSWORD HERE"; // password protect via http $_SERVER['PHP_AUTH_USER'] == $username && $_SERVER['PHP_AUTH_PW'] == $password)){ }else{ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Page Name</title> </head> <body> <!-- // html --> </body> </html> <?php } ?>
以上是关于简单PHP身份验证HTTP的主要内容,如果未能解决你的问题,请参考以下文章
php curl - 使用 http 身份验证访问 url(需要帮助)