Code : Tout sélectionner
#include <mysql.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <GuiButton.au3>
Global $prenom =""
Global $nom =""
Global $identifiant=""
Global $motdepasse
Global $idIsExist
Global $idIsOk
Global $mdpIsOk
Global $i_identifiant, $i_motdepasse, $i_nom, $i_prenom, $Button1, $ButtonOk
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 445, 193, 125)
$nouveau = GUICtrlCreateButton("nouvel utilisateur", 48, 72, 153, 25, 0)
$connection = GUICtrlCreateButton("se connecter", 48, 120, 153, 25, 0)
GUICtrlSetOnEvent($nouveau,"newUser_GUI")
GUICtrlSetOnEvent($connection,"connexionUser_GUI")
GUISetOnEvent($GUI_EVENT_CLOSE,"prog_CLOSE")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(10000)
WEnd
Func prog_CLOSE()
Exit
EndFunc
Func connexionUser_GUI()
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Connexion", 243, 137, -1, -1)
GUISetIcon("D:\008.ico")
$i_motdepasse = GUICtrlCreateInput("password", 3, 77, 233, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 81, 109, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Annuler", 162, 109, 75, 25, 0)
$Label = GUICtrlCreateLabel("Mot de passe :", 3, 57, 74, 17)
$Label1 = GUICtrlCreateLabel("Identifiant :", 8, 7, 56, 17)
$i_identifiant = GUICtrlCreateInput("Entre ton identifiant", 3, 27, 233, 21)
GUICtrlSetOnEvent($ButtonOk, "connexionUser")
GUICtrlSetOnEvent($ButtonCancel, "CLOSE_GUI")
HotKeySet("{ENTER}", "connexionUser_ENTER")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
EndFunc
Func connexionUser_ENTER()
HotKeySet("{ENTER}") ; Pour désactiver le HotKeySet.
_GUICtrlButton_Click($ButtonOk)
EndFunc
Func connexionUser()
$identifiant= GUICtrlRead($i_identifiant)
$motdepasse= GUICtrlRead($i_motdepasse)
;on va voir si les données sont bonne
$sql = _MySQLConnect("*****","*****","math","***.***.*.**")
$var = _Query($sql,"SELECT * FROM user WHERE id = '"& $identifiant&"'")
With $var
While NOT .EOF
$idIsOk=.Fields("id").value
$mdpIsOk=.Fields("mdp").value
.MoveNext
WEnd
EndWith
If $identifiant = $idIsOk And $motdepasse = $mdpIsOk Then
MsgBox(64, "OK !", "Identifiant et mot de passe correct")
CLOSE_GUI()
ElseIf $identifiant <> $idIsOk Then
MsgBox(48, "Identifiant inexistant", "Cet identifiant est inexistant, recommence.")
ElseIf $motdepasse <> $mdpIsOk Then
MsgBox(48, "Mot de passe incorect", "Entre le bon mot de passe")
EndIf
_MySQLEnd($sql)
EndFunc