简单的登录我想创建一个只有几个硬编码的用户名/密码连击简单的登录它可以访问个人的私有目录与我上传文件。 (mysite.com/user1/,mysite.com/anotheruser/...)私人用户文件
下面是我mylogin.php的内容。
“密码保护”的下载文件只有从这个页面,并通过各自的用户是什么样的方法有我吗?这些信息不会非常敏感,但应该有点安全。
<?php //List of users and their passwords
$users = array(
"myusername" => "mYpaSSw0rd2011",
"anothername" => "password2"
);?>
<html>
<head><title>Private Login</title></head>
<body>
<form method="POST" action="mylogin.php">
Username: <input type="text" name="username" size="15" /><br />
Password: <input type="password" name="password" size="15" /><br />
<input type="submit" value="Login" />
</form>
<?php //check username:password combo
if (isset($_POST["username"]) && $_POST["username"] != "" && ($users[$_POST["username"]] == $_POST["password"])
//*******************************************************
//list (private) files in mysite.com/username's directory
//*******************************************************
}?>
</body></html>
还好吧!我能够得到它的工作。花了一分钟的时间来围绕header()函数和文件/目录函数,但是你的建议让我指出了正确的方向。 – 2011-06-02 16:14:30