我正在尝试创建一个只能由注册用户访问的用户和信息的网页。是否可以限制未注册用户可以看到的文件?如果是这样,怎么样?我已经在index.php中有一个连接了MySQL数据库。这是我到目前为止:如何在给予注册用户完全访问权限的同时限制未注册用户的访问?
<head></head>
<body>
<h3>Signup Here:</h3>
<form method="post" action="userindex.php">
Please enter user name: <input type="text" name="username" value="" /><br />
Please enter password: <input type="password" name="password" value="" />
<br />
<input type="submit" value="Submit"/>
</form>
</body>
<?php
include ("dbroutines.php");
if (isset($_POST['username'])) {
if ($_POST['username']>'' && $_POST['password']>'') {
$q="insert into users (Name, Password) values ('".$_POST['username']."', '".$_POST['password']."')";
echo 'query='.$q;
$conn=db_connect();
$result=$conn->query($q);
echo '<br />xxx'.$conn->error."xxx";
unset($_POST['username']);
unset($_POST['password']);
} else {
echo 'Please enter both username AND password!';
}
}
$q="select Name, Password from users";
$conn=db_connect();
$result=$conn->query($q);
echo 'xxx'.$conn->error."xxx";
if ($result){
echo '<hr />';
for ($count=0; $row=$result->fetch_row(); ++$count) {
echo $count." Name=".$row[0]." password=".$row[1].'<br />';
}
echo '<b style="color:red;">there are '.$count.' users in your database!'.'</b><hr />';
}
由此,你可以指定什么样的用户可以访问某些文件,如userindex.php?
我不明白你的观点。你想在登录后给你的网站访问权限吗?你想要什么?你能再解释一次吗? – chintan 2013-03-27 02:51:33
我想要的是能够让客户端(未登录)对网站上的文件进行有限的访问,而同一用户在登录时可以访问网站上的文件。 – Max 2013-03-27 03:07:24