标签:http io os 使用 ar java for 数据 art
登陆页面login.php
session_start();
error_reporting(0);
require_once (‘include.php‘);
//未解决的问题:能匹配用户名,可是不能匹配密码。
// 导致结果:知道用户名,任意密码都能登陆
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>登陆</title>
</head>
<form method="post" action="login.php">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="user"> </td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="passwd"> </td>
</tr>
<tr>
<td><input type="submit" name="sub" value="提交"></td>
</tr>
</table>
</form>
<?php
echo "<br>";
if (isset($_POST[‘sub‘])) {
$user = $_POST[‘user‘];
$passwd = md5($_POST[‘passwd‘]);
checkLogin($user,$passwd);
}
?>
验证函数:login
// 判断用户登陆
function checkLogin($user,$passwd) {
echo "你输入的的账号是".$user.".<br>正在与数据库进行比对......";
//选择user表中的user,passwd与提交过来的的$user,$passwd进行对比
$sql = "select * from user where `user` = ‘{$user}‘ and `passwd` =‘$passwd‘ limit 1 ";
$query = mysql_query($sql);
//使用mysql_fetch_assoc进行数据集检索
$result = mysql_fetch_assoc($query);
if(!$result){
echo "比对失败".mysql_error();
}else{
echo "登陆成功";
}
}
标签:http io os 使用 ar java for 数据 art
原文地址:http://my.oschina.net/kopa/blog/323862