<?php
//解决乱码
header('Content-Type:text/html;charset=utf-8');
//接收表单-$_POST:表单中的数据:var_dump($_POST);
//验证数据
//用户名不能为空
if($_POST['username']=='')
{
exit('用户名不能为空!');
}
//密码不能为空
if($_POST['password']=='')
{
exit('密码不能为空!');
}
//不显示错误
error_reporting(0);
//连接数据库
mysql_connect('localhost','root','');
mysql_select_db('reading');
mysql_query('set names utf8');
//根据用户名查看有没有此用户
$sql="select password from member where username='$_POST[username]'";
//执行sql获取资源
$rs=mysql_query($sql);
//从资源中获取数据
$row=mysql_fetch_assoc($rs);
//判断否取出了数据
if ($row)
{
//因为会员注册时,密码被加密,所以登录时先把会员提交的密码加密后再与数据库密码对比
if ($row['password'] == md5($_POST['password']))
{
exit('登录成功!');
}
else
{
exit('密码错误!');
}
}
else{
//如果数据库中取不出数据
exit('用户名不存在!');
}
习惯受伤