예제 #1
0
 /**
  * 实现登陆验证的功能
  * @param string $username 用户名
  * @param string $password 密码
  * 
  * @return tb_user 的一个对象
  */
 public function userLogin($username, $password)
 {
     $query = "select username,truename,password,sex,tel,email,address,headimg from tb_user where username='******' and password='******'";
     $query = sprintf($query, $username, md5($password));
     $mysqli = new mysqli("127.0.0.1", "root", "7qlzxsyzx7", "db_forum");
     $mysqli->prepare("set names utf8")->execute();
     $user = null;
     if ($result = $mysqli->query($query)) {
         while ($row = $result->fetch_row()) {
             $user = new Tb_user();
             $user->setUsername($row['0']);
             $user->setTruename($row['1']);
             $user->setPassword($row['2']);
             $user->setSex($row['3']);
             $user->setTel($row['4']);
             $user->setEmail($row['5']);
             $user->setAddress($row['6']);
             $user->setHeadimg($row['7']);
             //var_dump($user);
         }
     }
     return $user;
 }
예제 #2
0
파일: Register.php 프로젝트: byvaio/test1
    return;
}
if ($tel == '') {
    header('Location:../login.php');
    return;
}
if ($email == '') {
    header('Location:../login.php');
    return;
}
if ($address == '') {
    header('Location:../login.php');
    return;
}
// 封装
$tb_user = new Tb_user();
$tb_user->setUsername($username);
$tb_user->setTruename($truename);
$tb_user->setPassword($password);
$tb_user->setSex($sex);
$tb_user->setTel($tel);
$tb_user->setEmail($email);
$tb_user->setAddress($address);
$tb_user->setHeadimg($headimg);
// 注册
$login = new Login();
$falag_register = $login->register($tb_user);
if ($falag_register) {
    header('Location:../index.php');
} else {
    header('Location:../login.php');