Jump to content

Autoit Login script (No ODBC) Problem


Recommended Posts

Hello i am having a problem with my code for the no ODBC Login , it always says succesful login EVEN if the account dosent exzist, or the PW is wrong,

Help me please,

Heres what i was trying to do, you login if your UN and PW exzist (same row of course,) and if the login is succesful it says so thenn., it checks another column in that same row to see if they have game time left, (ex. if you a4re out of game time ytou cant login)if you do have time left, it does a function

#include <array.au3>
#include <mysql.au3>
FileInstall("C:\Program Files\AutoIt3\Include\libmysql.dll", @HomeDrive & "\Windows\System\libmysql.dll")
_MySQL_InitLibrary(@HomeDrive & "\Windows\System\libmysql.dll")
If @error Then Exit MsgBox(0, '', "Error")
$MysqlConn = _MySQL_Init()

$connected = _MySQL_Real_Connect($MysqlConn, "localhost", "root", "ROOT", "forum")
If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn))

$yam = "Test"
$pass = "Test"
$TimeLeft = ""
$query1 = "SELECT " & $yam &" FROM Test WHERE Time='"  & _MySQL_Real_Escape_String($MysqlConn,$TimeLeft) & "'"
$query2 = "SELECT * FROM Test WHERE Username='"  & _MySQL_Real_Escape_String($MysqlConn,$yam) & "' AND Password='" & _MySQL_Real_Escape_String($MysqlConn,$pass) & "'"
If _MySQL_Real_Query($MysqlConn, $query2) = $MYSQL_ERROR Then
    MsgBox(0, 'Login Error',"Account not found , Exzact Error-" & _MySQL_Error($MysqlConn))
Else

;------------------------------------------------------


;------------------------------------------------------

$res = _MySQL_Store_Result($MysqlConn)
$users = _MySQL_Num_Rows($res)
MsgBox(0, '', "AccountFound")
If _MySQL_Real_Query($MysqlConn, $query1) = $MYSQL_ERROR Then
    MsgBox(0, 'Varification Error"You Are out of time, Please buy more"', _MySQL_Error($MysqlConn))
Else
    MsgBox(0,'',"AccountVerified, Enjoy")
EndIf

    
;~; Abfrage freigeben
_MySQL_Free_Result($res)
EndIf
;~; Verbindung beenden
_MySQL_Close($MysqlConn)
;~; MYSQL beenden
_MySQL_EndLibrary()

Help me fix this please

FIXED:

#include <array.au3>
#include "mysql.au3"

_MySQL_InitLibrary()
If @error Then Exit MsgBox(0, '', "")
$MysqlConn = _MySQL_Init()

$connected = _MySQL_Real_Connect($MysqlConn, "localhost", "root", "ROOT", "forum")
If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn))

$yam = "Test"
$pass = "Test"
$Time = "Test"

$query = "SELECT * FROM Test WHERE Username='"  & _MySQL_Real_Escape_String($MysqlConn,$yam) & "' AND password='" & _MySQL_Real_Escape_String($MysqlConn,$pass) & "' AND Time='" & _MySQL_Real_Escape_String($MysqlConn,$time) & "'"
MsgBox(0, '', $query)
If _MySQL_Real_Query($MysqlConn, $query) = $MYSQL_ERROR Then
    MsgBox(0, 'Error', _MySQL_Error($MysqlConn))
Else

;------------------------------------------------------


;------------------------------------------------------

$res = _MySQL_Store_Result($MysqlConn)
$users = _MySQL_Num_Rows($res)
if $users == 1 then;if the user is found 
MsgBox(0, '', "Account Found Login succesful.");what to do if the user is found 
;Unlock Tabs
Else
    MsgBox(0,'',"Login Failed EIther your UN and PW is wrong or you are out of time.");what to do if the UN and PW is not found
EndIf


;~; Abfrage freigeben
_MySQL_Free_Result($res)
EndIf
;~; Verbindung beenden
_MySQL_Close($MysqlConn)
;~; MYSQL beenden
_MySQL_EndLibrary()
Edited by liten

My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u]

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...