func register_User(user_info RegisterStruct) (string, error) { db := database.GetDb() defer db.Close() logErr := logger.GetErr() logInfo := logger.GetInfo() times := 0 rows, err := db.Query("select reg_times from userInfo where user_name = ? and if_use = 1", user_info.Username) if err != nil { logErr.Println(err) return "", err } for rows.Next() { err = rows.Scan(×) if err != nil { logErr.Println(err) return "", err } } if times != 0 { res := "This username is using." logInfo.Println(res) return res, nil } times++ stmt, err := db.Prepare("insert into userInfo(reg_times,user_name,user_cert) values(?,?,?)") if err != nil { logErr.Println(err) return "", err } _, err = stmt.Exec(times, user_info.Username, user_info.Psw1) if err != nil { logErr.Println(err) return "", err } return "", nil }
"common" "database/Dbase" "fmt" "github.com/gorilla/securecookie" "html/template" "logger" "net/http" ) func Init() { ResultTypeInit() UserOnline = make(map[string]string) } var res_type_info ResultType var logInfo = logger.GetInfo() var logWar = logger.GetWar() var logErr = logger.GetErr() var logDeb = logger.GetSuc() func RegisterHandler(w http.ResponseWriter, r *http.Request) { fmt.Println(r.Method) if r.Method == "GET" { reg_Info := Reg_Type_Info{ IsHide: "none", Info: "", BackShow: false, }