Пример #1
0
/**
*检查用户名是否存在
 */
func CheckUserName(uname string) bool {
	var property []string = []string{"name"}
	rows, _ := dbutil.Query("user_pwd", property, "name = "+"'"+uname+"'", "", "")
	if rows == nil {
		return false
	}
	for rows.Next() {
		var name string
		err := rows.Scan(&name)
		if err != nil {
			logger.Println(err)
			continue
		}
		logger.Println(name)
		if uname == name {
			return true
		}
	}
	return false
}
Пример #2
0
/**
*检查用户名密码是否正确
 */
func CheckUserPwd(uname string, pwd string) bool {
	var property []string = []string{"name", "password"}
	rows, _ := dbutil.Query("user_pwd", property, "name = "+"'"+uname+"'", "", "")
	if rows == nil {
		return false
	}
	for rows.Next() {
		var name string
		var password string
		err := rows.Scan(&name, &password)
		if err != nil {
			logger.Println(err)
			continue
		}
		logger.Println(name, password)
		if uname == name && password == pwd {
			return true
		}
	}
	return false
}