Update main.go
This commit is contained in:
parent
17c5b6ce67
commit
ee70df18ec
64
main.go
64
main.go
@ -17,33 +17,37 @@ import (
|
|||||||
func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
|
func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
|
||||||
t, _ := template.ParseFiles("StronaGlowna.gtpl")
|
t, _ := template.ParseFiles("StronaGlowna.gtpl")
|
||||||
t.Execute(w, nil)
|
t.Execute(w, nil)
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", "stolowkaZPM.db")
|
|
||||||
checkErr(err)
|
|
||||||
// query
|
|
||||||
rows, err := db.Query("SELECT * FROM users")
|
|
||||||
checkErr(err)
|
|
||||||
var IDusers int64
|
|
||||||
var Username string
|
|
||||||
var Password string
|
|
||||||
var PIN int
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
err = rows.Scan(&IDusers, &Username, &Password, &PIN)
|
|
||||||
checkErr(err)
|
|
||||||
fmt.Printf("%d, %s, %s, %d \n ", IDusers, Username, Password, PIN)
|
|
||||||
fmt.Fprintln("w \n", Username)
|
|
||||||
}
|
|
||||||
rows.Close()
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func panel(w http.ResponseWriter, r *http.Request) {
|
func panel(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Println("method:", r.Method)
|
fmt.Println("method:", r.Method)
|
||||||
t, _ := template.ParseFiles("panel.gtpl")
|
t, _ := template.ParseFiles("panel.gtpl")
|
||||||
t.Execute(w, nil)
|
t.Execute(w, nil)
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
db, err := sql.Open("sqlite3", "stolowkaZPM.db")
|
||||||
|
checkErr(err)
|
||||||
|
// query
|
||||||
|
rows, err := db.Query("SELECT * FROM users")
|
||||||
|
checkErr(err)
|
||||||
|
var IDusers int
|
||||||
|
var Username string
|
||||||
|
var Password string
|
||||||
|
var PIN int
|
||||||
|
var RFID int
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
err = rows.Scan(&IDusers, &Username, &Password, &PIN, &RFID)
|
||||||
|
checkErr(err)
|
||||||
|
fmt.Printf("%d, %s, %s, %d, %d \n", IDusers, Username, Password, PIN, RFID)
|
||||||
|
fmt.Fprintln(w, IDusers)
|
||||||
|
fmt.Fprintln(w, ". ")
|
||||||
|
fmt.Fprintln(w, Username)
|
||||||
|
fmt.Fprintln(w, "\n")
|
||||||
|
}
|
||||||
|
rows.Close()
|
||||||
|
db.Close()
|
||||||
|
//***************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
func login(w http.ResponseWriter, r *http.Request) {
|
func login(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -54,23 +58,23 @@ func login(w http.ResponseWriter, r *http.Request) {
|
|||||||
t.Execute(w, nil)
|
t.Execute(w, nil)
|
||||||
} else {
|
} else {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
fmt.Println("username:", r.Form["username"])
|
fmt.Println("usernameFROMsite: ", r.Form["usernameFROMsite"])
|
||||||
fmt.Println("password:", r.Form["password"])
|
fmt.Println("passwordFROMsite: ", r.Form["passwordFROMsite"])
|
||||||
//if len(r.Form["username"][0]) == 0 {
|
//if len(r.Form["usernameFROMsite"][0]) == 0 {
|
||||||
// goto Here
|
// goto Here
|
||||||
//}
|
//}
|
||||||
//if len(r.Form["password"][0]) == 0 {
|
//if len(r.Form["passwordFROMsite"][0]) == 0 {
|
||||||
// goto Here
|
// goto Here
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
username := r.Form["username"]
|
usernameFROMsite := r.Form["usernameFROMsite"]
|
||||||
password := r.Form["password"]
|
passwordFROMsite := r.Form["passwordFROMsite"]
|
||||||
zaloguj := "Wpisane wartości:"
|
zaloguj := "Wpisane wartości:"
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
if zaloguj != "" {
|
if zaloguj == "Wpisane wartości:" {
|
||||||
fmt.Fprintln(w, zaloguj)
|
fmt.Fprintln(w, zaloguj)
|
||||||
fmt.Fprintln(w, username)
|
fmt.Fprintln(w, usernameFROMsite)
|
||||||
fmt.Fprintln(w, password)
|
fmt.Fprintln(w, passwordFROMsite)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user