Jump to content

[Solved] Login Script with MySql database


simkpa
 Share

Recommended Posts

Hi everyone !

I try to make a login script by using a Mysql database.

I use because he looks easier to use than and the real autoit code.

So i do this :

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "mysql.au3"
#include <SQLite.au3>
#include <SQLite.dll.au3>

Dim $wait

#Region ### START Koda GUI section ### Form= Identification
$ID_Form = GUICreate("Identification", 259, 123, 192, 124)
$NdC_Lbl = GUICtrlCreateLabel("Nom de compte ", 16, 16, 82, 17)
$PsWd_Lbl = GUICtrlCreateLabel("Mot de passe", 16, 48, 68, 17)
$NdC_Input = GUICtrlCreateInput("", 120, 16, 121, 21)
$PsWd_Input = GUICtrlCreateInput("", 120, 48, 121, 21)
$Login_Btn = GUICtrlCreateButton("Connexion a la messagerie", 16, 80, 225, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ### Form= Identification

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Login_Btn
$NdC = GUICtrlRead ($NdC_Input)
$PsWd = GUICtrlRead ($PsWd_Input)
$UserName = "root"
$Password = ""
$Database = "oom_messagerie"
$MySQLServerName = "127.0.0.1"
$Mysql_connexion = _MySQLConnect($UserName,$Password,$Database,$MySQLServerName,"{MySQL ODBC 3.51 Driver}",3306)

If @error Then
_Erreur_1 ()
EndIf

$connexion_requette1 = "select ID from utilisateur where NdC ='"& $NdC &"' AND PsWd ='"& $PsWd &"'"
$req = _Query ($Mysql_connexion,$connexion_requette1)

If @error Then
_Erreur_2 ()
EndIf
While 1
If $req <> 0 Then
MsgBox (0,"Victory","Sa marche bro !") ;work test msgbox
ExitLoop
Else
Sleep (1000)
$wait = $wait+1
If $wait = 5 Then
MsgBox (0,"Fail","Tjr pas dude :/"& @error) ;fail test msgbox
ExitLoop
EndIf
EndIf
WEnd
_MySQLEnd($Mysql_connexion)

EndSwitch
WEnd


Func _Erreur_1 ()
MsgBox (61,"OUTCH !","Epic Fail ! erreur de connexion a la database ")
EndFunc

Func _Erreur_2 ()
MsgBox (61,"OUTCH !","Epic Fail ! erreur dans la requette de la table")
EndFunc

I think that my script can connect to the database but i cant get the value of query.

I'm in LocalHost ( Xampp ) with ODBC instaled, my database is call oom_messagerie and my table oom_connexion .

I work 2 days on it and i really hit my head on the keyboard right now ... I'm not very strong in Autoit and juste begin Mysql so i really need some help :)

Thanks everyone !

PS : I'm french ! sorry for the worst english you ever seen !!!

Edited by simkpa
Link to comment
Share on other sites

Hello!

I have to be honest, I've never used the MySQL UDF's... Instead, I use the SQLite UDF's... A while back I posted a script which relies on a database. You can see it here:

With luck it might give you some ideas with MySQL or convert you to SQLite.... Or, give you something to do while you wait for someone with MySQL experience ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...