.htpasswd 主要是 apache 使用的基于文件的用户名和密码的存储
<?php // - - - - - - - - - - - - - - - - - - - // Author: Christopher Hair // Website: www.chrishair.co.uk // - - - - - - - - - - - - - - - - - - - if (isset($_POST['submit'])){ $error = ''; $username = trim(stripslashes($_POST['username'])); $password = trim(stripslashes($_POST['password'])); if ($username == '' || preg_match('/\s/m', $username)) { $error .= "<p><strong>Invalid Username.</strong></p>\n"; } if ($password == '' || preg_match('/\s/m', $password)) { $error .= "<p><strong>Invalid Password.</strong></p>\n"; } if ($error == '') { echo "<p>Success</p>\n"; echo "<h1>" . htmlspecialchars($username) . ":" . crypt($password) . "</h1>\n"; } else { echo $error; } } ?>
以上就是PHP 生成 .htpasswd 文件的用户名和密码的内容,更多相关内容请关注PHP中文网(www.php.cn)!