日期:2014-05-16 浏览次数:20498 次
<html>
<head>
<title>管理员登录</title>
</head>
<body>
<form action="active.php" method="POST">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="text" name="pass"></td>
</tr>
<tr>
<td rows="2"><input type="submit" value ="登录"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("blog",$link);
mysql_query("set names utf8");
$sql="select * from user where username='$user'";
$result=mysql_query($sql);
while($row=mysql_fetch_row($result)){
$username=$row['username'];//用单引号就是不行。
$password=$row[2];
}
echo $username;
echo "<hr>";
echo $password;
?>