• 软工每日总结28


    今天我们决定对用户交互的不足进行修改,主要内容就是添加用户登录的功能。我的任务是完成数据在后台的处理,今天完成的是服务器的部分,使用php完成,主要部分是sql类,提供对用户表的各种操作,以及对错误信息的反馈,数据传输采用json完成。另外,今天也完成了一部分之前程序的修正,经过测试发现某次模块化改进之后的缓存系统并没有正常工作,于是经过检查,解决了问题。

    主要代码:

    function login($email,$pw)
    {
    global $DB_H;global $debug;
    $sql = "SELECT * FROM {$DB_H}Users WHERE `email`="{$email}" AND `password`="{$pw}"";
    if($debug==1)
    {
    echo $sql;
    }
    $result = $this->mysqli->query($sql);
    $row = mysqli_fetch_array($result);
    if ($row)
    {
    $this->json_out_error("true","login",$row['id']);
    $_SESSION['id']=$this->get_id($email, $pw);
    }else if(!$this->user_existed($email))
    {
    $this->json_out_error("false","email haven't registed!".$email);
    }else
    {
    $this->json_out_error("false","login failed;um=".$email."pw:".$pw);
    }
    $result->close();
    }

    function insert_user($email,$pw)
    {
    //echo $email.$pw;
    global $DB_H;
    $re = $this->user_existed($email);
    //echo $re;
    if($re)
    {
    $this->json_out_error("false","email already existed!");
    }
    else
    {
    $sql = "INSERT INTO {$DB_H}Users (email, password) VALUES ("{$email}","{$pw}")";
    $t=$this->mysqli->query($sql);
    if ($t)
    {
    $this->json_out_error("true","registed",$this->get_id($email, $pw));
    $_SESSION['id']=$this->get_id($email, $pw);
    }
    else
    {
    $this-> json_out_error("false",-1);
    }
    }
    }
  • 相关阅读:
    迭代器生成器
    elasticsearch系列(五)score
    数据结构(五)串
    数据结构系列(四)栈与队列
    数据结构系列(三)线性表
    数据结构系列(二)算法
    数据结构系列(一)入门
    elasticsearch系列(四)部署
    SpringBoot系列(一)RestTemplate
    基于python的爬虫(一)
  • 原文地址:https://www.cnblogs.com/evi10032/p/5628179.html
Copyright © 2020-2023  润新知