Update main.go
This commit is contained in:
parent
977dfbe4c5
commit
51b02276b8
55
main.go
55
main.go
@ -59,8 +59,8 @@ func login(w http.ResponseWriter, r *http.Request) {
|
|||||||
t.Execute(w, nil)
|
t.Execute(w, nil)
|
||||||
} else {
|
} else {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
fmt.Println("usernameFROMsite: ", r.Form["usernameFROMsite"])
|
//fmt.Println("usernameFROMsite: ", r.Form["usernameFROMsite"])
|
||||||
fmt.Println("passwordFROMsite: ", r.Form["passwordFROMsite"])
|
//fmt.Println("passwordFROMsite: ", r.Form["passwordFROMsite"])
|
||||||
//if len(r.Form["usernameFROMsite"][0]) == 0 {
|
//if len(r.Form["usernameFROMsite"][0]) == 0 {
|
||||||
// goto Here
|
// goto Here
|
||||||
//}
|
//}
|
||||||
@ -68,16 +68,51 @@ func login(w http.ResponseWriter, r *http.Request) {
|
|||||||
// goto Here
|
// goto Here
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
usernameFROMsite := r.Form["usernameFROMsite"]
|
usernameFROMsite := r.FormValue("usernameFROMsite")
|
||||||
passwordFROMsite := r.Form["passwordFROMsite"]
|
passwordFROMsite := r.FormValue("passwordFROMsite")
|
||||||
zaloguj := "Wpisane wartości:"
|
zaloguj := "Zalogowano!"
|
||||||
if r.Method == "POST" {
|
|
||||||
if zaloguj == "Wpisane wartości:" {
|
//***************************************************************************
|
||||||
fmt.Fprintln(w, zaloguj)
|
db, err := sql.Open("sqlite3", "stolowkaZPM.db")
|
||||||
fmt.Fprintln(w, usernameFROMsite)
|
checkErr(err)
|
||||||
fmt.Fprintln(w, passwordFROMsite)
|
// query
|
||||||
|
rows, err := db.Query("SELECT * FROM users")
|
||||||
|
checkErr(err)
|
||||||
|
var IDusers int
|
||||||
|
var User string
|
||||||
|
var Password string
|
||||||
|
var PIN int
|
||||||
|
var RFID int
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
err = rows.Scan(&IDusers, &User, &Password, &PIN, &RFID)
|
||||||
|
checkErr(err)
|
||||||
|
//fmt.Printf("%d. %s, %s, %d, %d \n", IDusers, User, Password, PIN, RFID)
|
||||||
|
//fmt.Fprint(w, IDusers)
|
||||||
|
//fmt.Fprint(w, ". ")
|
||||||
|
//fmt.Fprint(w, User)
|
||||||
|
//fmt.Fprint(w, " \n")
|
||||||
|
if r.Method == "POST" {
|
||||||
|
if User == usernameFROMsite {
|
||||||
|
if Password == passwordFROMsite {
|
||||||
|
fmt.Fprintln(w, zaloguj)
|
||||||
|
fmt.Fprintln(w, usernameFROMsite)
|
||||||
|
fmt.Fprintln(w, passwordFROMsite)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if r.Method == "POST" {
|
||||||
|
if usernameFROMsite != User {
|
||||||
|
t, _ := template.ParseFiles("login.gtpl")
|
||||||
|
t.Execute(w, nil)
|
||||||
|
fmt.Fprint(w, "*** UWAGA! *** Błąd logowania! *** Spróbuj ponownie. ***")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows.Close()
|
||||||
|
db.Close()
|
||||||
|
//***************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user