[PHP] 纯文本查看 复制代码
<body>
<form action="chuli.php" method="post">
<p style="margin-left: 500px; margin-top: 200px;
height: 250px; width: 250px; border: 1px dashed black">
<p style="margin-left: 100px; "><h3>登录</h3></p>
<p style="margin-top: 20px">用户名:<input type="text" name="uid"/></p><br/>
<p>密 码:<input type="password" name="pwd"/></p><br/>
<p style="margin-left: 180px"><input type="submit" value="登录"/></p>
</p>
</form>
</body>
[PHP] 纯文本查看 复制代码
<?php
session_start(); //开启session 必须要写到第一行
header("Content-type:text/html;charset=utf-8");
$uid=$_POST["uid"]; //从登录页面获取到用户名和密码
$pwd=$_POST["pwd"];
include("DADB.class.php");
$db=new DADB();
$sql="select password from login where username='{$uid}'";
$arr=$db->Query($sql);
if($arr[0][0]==$pwd && !empty($pwd)) //判断所填写的密码和取到的密码是一样的,而且密码不能为空
{
$_SESSION["uid"]=$uid;
header("location:main.php");
}
else
{
echo"登录失败";
}