Jump to content

why not ini handle


tuanvu
 Share

Recommended Posts

Help me fix the source
thank you
 
I want to handle at the command
  
            If $check <> @error Then
  1.                 If $user <> $check[1][0] Then
  2.                 MsgBox(16, $title, "Tài khoảng không tồn tại", 3)

 

 

  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <StaticConstants.au3>
  5. #include <WindowsConstants.au3>
  6.  
  7. Global $title = "[GUI] Login & Register"
  8. Global $file = @ScriptDir & "\data.ini"
  9.  
  10. #Region ### START Koda GUI section ### Form=
  11. Global $Form = GUICreate($title, 308, 135, 352, 307)
  12. GUISetFont(10, 400, 0, "Arial")
  13. GUISetBkColor(0xFFFFFF)
  14. Global $Label_User = GUICtrlCreateLabel("Tài khoảng", 3, 8, 67, 20)
  15. Global $Label_Pass = GUICtrlCreateLabel("Mật khẩu", 3, 40, 58, 20)
  16. Global $Input_User = GUICtrlCreateInput("", 80, 5, 225, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
  17. Global $Input_Pass = GUICtrlCreateInput("", 80, 37, 225, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD))
  18. Global $Radio_Login = GUICtrlCreateRadio("Đăng nhập", 3, 72, 89, 25)
  19. GUICtrlSetState(-1, $GUI_CHECKED)
  20. Global $Radio_Reg = GUICtrlCreateRadio("Đăng ký", 3, 104, 89, 25)
  21. Global $Button = GUICtrlCreateButton("Đăng nhập", 130, 72, 130, 57)
  22. Dim $Form1_AccelTable[1][2] = [["{Enter}", $Button]]
  23. GUISetAccelerators($Form1_AccelTable)
  24. #EndRegion ### END Koda GUI section ###
  25.  
  26. While 1
  27.         $nMsg = GUIGetMsg()
  28.         Switch $nMsg
  29.                 Case $GUI_EVENT_CLOSE
  30.                         Exit
  31.                 Case $Radio_Login
  32.                         GUICtrlSetData($Button, "Đăng nhập")
  33.                 Case $Radio_Reg
  34.                         GUICtrlSetData($Button, "Đăng ký")
  35.                 Case $Button
  36.                         If GUICtrlRead($Radio_Reg) = 1 Then
  37.                                 _Reg()
  38.                         Else
  39.                                 _Login()
  40.                         EndIf
  41.         EndSwitch
  42.  
  43. Func _Reg()
  44.         $user = GUICtrlRead($Input_User)
  45.         $pass = GUICtrlRead($Input_Pass)
  46.  
  47.         If StringLen($user) < 3 Then
  48.                 MsgBox(16, $title, "Tài khoảng không được bé hơn 4 kí tự")
  49.         ElseIf StringLen($pass) < 3 Then
  50.                 MsgBox(16, $title, "Mật khẩu không được bé hơn 4 kí tự")
  51.         ElseIf $user = $pass Then
  52.                 MsgBox(16, $title, "Tài khoảng và mật khẩu không trùng nhau!")
  53.         Else
  54.                 IniWrite($file, $user, $user, $pass)
  55.                 MsgBox(64, $title, "Đăng kí thành công!", 3)
  56.                 GUICtrlSetData($Input_User, "")
  57.                 GUICtrlSetData($Input_Pass, "")
  58.                 GUICtrlSetState($Radio_Login, 1)
  59.         EndIf
  60.  
  61. Func _Login()
  62.         $user = GUICtrlRead($Input_User)
  63.         $pass = GUICtrlRead($Input_Pass)
  64.         $check = IniReadSection($file, $user)
  65.  
  66.         If $check <> @error Then
  67.                 If $user <> $check[1][0] Then
  68.                         MsgBox(16, $title, "Tài khoảng không tồn tại", 3)
  69.                 ElseIf $pass <> $check[1][1] Then
  70.                         MsgBox(16, $title, "Sai mật khẩu", 3)
  71.                 ElseIf $user = $check[1][0] And $pass = $check[1][1] Then
  72.                         MsgBox(64, $title, "Đăng nhập thành công!", 3)
  73.                 Else
  74.                 EndIf
  75.         EndIf

 

Link to comment
Share on other sites

Help me fix the source
thank you
 
I want to handle at the command

 

If $check <> @error Then
  1.                 If $user <> $check[1][0] Then
  2.                 MsgBox(16, $title, "Tài khoảng không tồn tại", 3)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
Global $title = "[GUI] Login & Register"
Global $file = @ScriptDir & "\data.ini"
 
#Region ### START Koda GUI section ### Form=
Global $Form = GUICreate($title, 308, 135, 352, 307)
GUISetFont(10, 400, 0, "Arial")
GUISetBkColor(0xFFFFFF)
Global $Label_User = GUICtrlCreateLabel("Tài khoảng", 3, 8, 67, 20)
Global $Label_Pass = GUICtrlCreateLabel("Mật khẩu", 3, 40, 58, 20)
Global $Input_User = GUICtrlCreateInput("", 80, 5, 225, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
Global $Input_Pass = GUICtrlCreateInput("", 80, 37, 225, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD))
Global $Radio_Login = GUICtrlCreateRadio("Đăng nhập", 3, 72, 89, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Radio_Reg = GUICtrlCreateRadio("Đăng ký", 3, 104, 89, 25)
Global $Button = GUICtrlCreateButton("Đăng nhập", 130, 72, 130, 57)
Dim $Form1_AccelTable[1][2] = [["{Enter}", $Button]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Radio_Login
                        GUICtrlSetData($Button, "Đăng nhập")
                Case $Radio_Reg
                        GUICtrlSetData($Button, "Đăng ký")
                Case $Button
                        If GUICtrlRead($Radio_Reg) = 1 Then
                                _Reg()
                        Else
                                _Login()
                        EndIf
        EndSwitch
WEnd
 
Func _Reg()
        $user = GUICtrlRead($Input_User)
        $pass = GUICtrlRead($Input_Pass)
 
        If StringLen($user) < 3 Then
                MsgBox(16, $title, "Tài khoảng không được bé hơn 4 kí tự")
        ElseIf StringLen($pass) < 3 Then
                MsgBox(16, $title, "Mật khẩu không được bé hơn 4 kí tự")
        ElseIf $user = $pass Then
                MsgBox(16, $title, "Tài khoảng và mật khẩu không trùng nhau!")
        Else
                IniWrite($file, $user, $user, $pass)
                MsgBox(64, $title, "Đăng kí thành công!", 3)
                GUICtrlSetData($Input_User, "")
                GUICtrlSetData($Input_Pass, "")
                GUICtrlSetState($Radio_Login, 1)
        EndIf
EndFunc
 
Func _Login()
        $user = GUICtrlRead($Input_User)
        $pass = GUICtrlRead($Input_Pass)
        $check = IniReadSection($file, $user)
 
        If $check <> @error Then
                If $user <> $check[1][0] Then
                        MsgBox(16, $title, "Tài khoảng không tồn tại", 3)
                ElseIf $pass <> $check[1][1] Then
                        MsgBox(16, $title, "Sai mật khẩu", 3)
                ElseIf $user = $check[1][0] And $pass = $check[1][1] Then
                        MsgBox(64, $title, "Đăng nhập thành công!", 3)
                Else
                EndIf
        EndIf
EndFunc
Link to comment
Share on other sites

Help me fix the source
thank you
 
I want to handle at the command

 

If $check <> @error Then
  1.                 If $user <> $check[1][0] Then
  2.                 MsgBox(16, $title, "Tài khoảng không tồn tại", 3)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
Global $title = "[GUI] Login & Register"
Global $file = @ScriptDir & "\data.ini"
 
#Region ### START Koda GUI section ### Form=
Global $Form = GUICreate($title, 308, 135, 352, 307)
GUISetFont(10, 400, 0, "Arial")
GUISetBkColor(0xFFFFFF)
Global $Label_User = GUICtrlCreateLabel("Tài khoảng", 3, 8, 67, 20)
Global $Label_Pass = GUICtrlCreateLabel("Mật khẩu", 3, 40, 58, 20)
Global $Input_User = GUICtrlCreateInput("", 80, 5, 225, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
Global $Input_Pass = GUICtrlCreateInput("", 80, 37, 225, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD))
Global $Radio_Login = GUICtrlCreateRadio("Đăng nhập", 3, 72, 89, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Radio_Reg = GUICtrlCreateRadio("Đăng ký", 3, 104, 89, 25)
Global $Button = GUICtrlCreateButton("Đăng nhập", 130, 72, 130, 57)
Dim $Form1_AccelTable[1][2] = [["{Enter}", $Button]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Radio_Login
                        GUICtrlSetData($Button, "Đăng nhập")
                Case $Radio_Reg
                        GUICtrlSetData($Button, "Đăng ký")
                Case $Button
                        If GUICtrlRead($Radio_Reg) = 1 Then
                                _Reg()
                        Else
                                _Login()
                        EndIf
        EndSwitch
WEnd
 
Func _Reg()
        $user = GUICtrlRead($Input_User)
        $pass = GUICtrlRead($Input_Pass)
 
        If StringLen($user) < 3 Then
                MsgBox(16, $title, "Tài khoảng không được bé hơn 4 kí tự")
        ElseIf StringLen($pass) < 3 Then
                MsgBox(16, $title, "Mật khẩu không được bé hơn 4 kí tự")
        ElseIf $user = $pass Then
                MsgBox(16, $title, "Tài khoảng và mật khẩu không trùng nhau!")
        Else
                IniWrite($file, $user, $user, $pass)
                MsgBox(64, $title, "Đăng kí thành công!", 3)
                GUICtrlSetData($Input_User, "")
                GUICtrlSetData($Input_Pass, "")
                GUICtrlSetState($Radio_Login, 1)
        EndIf
EndFunc
 
Func _Login()
        $user = GUICtrlRead($Input_User)
        $pass = GUICtrlRead($Input_Pass)
        $check = IniReadSection($file, $user)
 
        If $check <> @error Then
                If $user <> $check[1][0] Then
                        MsgBox(16, $title, "Tài khoảng không tồn tại", 3)
                ElseIf $pass <> $check[1][1] Then
                        MsgBox(16, $title, "Sai mật khẩu", 3)
                ElseIf $user = $check[1][0] And $pass = $check[1][1] Then
                        MsgBox(64, $title, "Đăng nhập thành công!", 3)
                Else
                EndIf
        EndIf
EndFunc
Link to comment
Share on other sites

  • Moderators

tuanvu,

Welcome to the AutoIt forums. But in future, please stick to just the one thread at a time.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

tuanvu,

This statement makes no sense...

If $check <> @error Then

IniReadSection returns an array.  @ERROR is set by the function to indicate status.  From the Help file

Return Value

Success: a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.
Failure: sets the @error flag to non-zero if unable to read the section (The INI file may not exist or the section may not exist or is empty)

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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