Trying logearme
with username and password from your own database, does not make the correct comparison in if
and skips to condition else
.
Code
import mysql.connector
import sys
from Tkinter import *
dato={
"user":"root",
"password":"",
"database":"baseusuarios",
"host":"127.0.0.1"
}
conexion=mysql.connector.connect(** dato)
cursor=conexion.cursor(buffered=True)
def Usuario():
ventUsuario=Tk()
ventUsuario.geometry("250x200+500+120")
ventUsuario.title("Sistema")
Usu=Label(ventUsuario,text="Usuario:",font=("Agency FB",14)).place(x=5,y=10)
cajaU=Entry(ventUsuario)
cajaU.place(x=100,y=20)
Contrasena=Label(ventUsuario,text="Contraseña:",font=("Agency FB",14)).place(x=5,y=50)
cajaC=Entry(ventUsuario,show="*")
cajaC.place(x=100,y=60)
botonU=Button(ventUsuario,text="Ingresar",command=lambda:ingresar(cajaU,cajaC))
botonU.place(x=100,y=100)
botonA=Button(ventUsuario,text="Crear una cuenta",command=lambda:cuentas(ventUsuario))
botonA.place(x=75,y=150)
ventUsuario.mainloop()
def ingresar(cajaU,cajaC):
Usuario=cajaU.get()
Contra=cajaC.get()
nom="hola"
ventIngresar=Tk()
ventIngresar.geometry("300x200+500+120")
ventIngresar.title("Ingresando al Sistema")
if(cursor.execute("SELECT * FROM 'usuarios' WHERE 'nombre'='" + Usuario
+ "' AND 'contrasena'='"+ Contra + "'")):
var2nombre=Label(ventIngresar,text="Has ingresado correctamente al sistema",font=("Agency FB",14)).place(x=10,y=10)
else:
varnombre=Label(ventIngresar,text="Usuario o Contraseña incorrecta",font=("Agency FB",14)).place(x=10,y=10)
ventIngresar.mainloop()