Update main.go

This commit is contained in:
s441433 2018-12-29 01:36:46 +01:00
parent 17c5b6ce67
commit ee70df18ec

64
main.go
View File

@ -17,33 +17,37 @@ import (
func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("StronaGlowna.gtpl")
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) {
fmt.Println("method:", r.Method)
t, _ := template.ParseFiles("panel.gtpl")
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) {
@ -54,23 +58,23 @@ func login(w http.ResponseWriter, r *http.Request) {
t.Execute(w, nil)
} else {
r.ParseForm()
fmt.Println("username:", r.Form["username"])
fmt.Println("password:", r.Form["password"])
//if len(r.Form["username"][0]) == 0 {
fmt.Println("usernameFROMsite: ", r.Form["usernameFROMsite"])
fmt.Println("passwordFROMsite: ", r.Form["passwordFROMsite"])
//if len(r.Form["usernameFROMsite"][0]) == 0 {
// goto Here
//}
//if len(r.Form["password"][0]) == 0 {
//if len(r.Form["passwordFROMsite"][0]) == 0 {
// goto Here
//}
}
username := r.Form["username"]
password := r.Form["password"]
usernameFROMsite := r.Form["usernameFROMsite"]
passwordFROMsite := r.Form["passwordFROMsite"]
zaloguj := "Wpisane wartości:"
if r.Method == "POST" {
if zaloguj != "" {
if zaloguj == "Wpisane wartości:" {
fmt.Fprintln(w, zaloguj)
fmt.Fprintln(w, username)
fmt.Fprintln(w, password)
fmt.Fprintln(w, usernameFROMsite)
fmt.Fprintln(w, passwordFROMsite)
}
}
}