Guest User

Untitled

a guest
Jan 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. import sqlite3
  2. conn = sqlite3.connect('HandwritingRecognition.db')
  3. c = conn.cursor()
  4.  
  5. def Create():
  6. c.execute('CREATE TABLE IF NOT EXISTS Users(FirstName TEXT, Surname TEXT, Username TEXT, Passwrd TEXT)')
  7.  
  8. def Data_Entry(self):
  9. FirstName = self.ids.FirstName.text
  10. Surname = self.ids.Surname.text
  11. Username = FirstName+Surname
  12. Passwrd = self.ids.Passwrd.text
  13. c.execute("INSERT INTO Users (FirstName,Surname,Username,Passwrd) VALUES(?,?,?,?)",(FirstName,Surname,Username,Passwrd))
  14. conn.commit()
  15.  
  16. def Find_User(self):
  17. finduser = ('SELECT * FROM Users WHERE Username = ? AND Passwrd = ?')
  18. c.execute(finduser,[(self.ids.Username.text),(self.ids.Passwrd.text)])
  19. data = c.fetchall()
  20. if data:
  21. return True
  22. else:
  23. return False
  24.  
  25. def Delete_User(USER):
  26. c.execute("DELETE FROM Users WHERE Username = ?",(USER,))
  27. conn.commit()
  28.  
  29. <RootWidget>:
  30. id: Main
  31. Login_Screen:
  32. id: login
  33. name: "Login_Screen"
  34. Change_Password:
  35. id: ChangePass
  36. name: 'Change_Password'
  37. Login_Failed:
  38. id: Failed
  39. name: "Login_Failed"
  40. Login_Successful:
  41. id: Success
  42. name: 'Login_Successful'
  43. Registration_Screen:
  44. id: register
  45. name: 'Registration_Screen'
  46.  
  47.  
  48. <Login_Screen>:
  49. GridLayout:
  50. rows:3
  51. cols:2
  52. Label:
  53. text: "Username:"
  54. font_size: 20
  55. TextInput:
  56. id: Username
  57. multiline: False
  58. hint_text: 'Enter your Username'
  59. Label:
  60. text: "Password"
  61. font_size: 20
  62. TextInput:
  63. id: Passwrd
  64. multiline: False
  65. hint_text: 'Enter your Password'
  66. password: True
  67. Button:
  68. text: "Register"
  69. background_color: (1,0,0,1)
  70. on_press: root.registration()
  71. Button:
  72. text: "Sign In"
  73. on_press: root.Login()
  74.  
  75. <Registration_Screen>:
  76. GridLayout:
  77. rows:4
  78. cols:2
  79. Label:
  80. text: 'First Name:'
  81. font_size: 20
  82. TextInput:
  83. id: FirstName
  84. multiline: False
  85. hint_text: 'Enter your First Name'
  86. Label:
  87. text: 'Surname'
  88. font_size: 20
  89. TextInput:
  90. id: Surname
  91. multiline: False
  92. hint_text: 'Enter your Surname'
  93. Label:
  94. text: 'Password'
  95. font_size: 20
  96. TextInput:
  97. id: Passwrd
  98. multiline: False
  99. hint_text: 'Enter your Password'
  100. password: False
  101. Button:
  102. text: "Create Account"
  103. on_press: root.MainScreen()
  104.  
  105. <Change_Password>
  106. FloatLayout:
  107. Label:
  108. text: 'Change Password'
  109. pos_hint: {"center_x":0.5, "y":0.75}
  110. font_size: '25sp'
  111. size_hint: 0.5,0.25
  112. Label:
  113. text:'Old Password:'
  114. pos_hint: {"x":0.2, "y":0.6}
  115. font_size: '25sp'
  116. size_hint: 0.3,0.1
  117. TextInput:
  118. pos_hint: {"x": 0.5,"y": 0.6}
  119. size_hint: 0.3,0.1
  120. id: OldPass
  121. multiline: False
  122. password: True
  123.  
  124.  
  125.  
  126. <Login_Successful>:
  127. FloatLayout:
  128. Label:
  129. text: 'Main Menu'
  130. pos_hint: {"center_x":0.5, "y":0.75}
  131. font_size: '25sp'
  132. size_hint: 0.5,0.25
  133. Button:
  134. text: 'Handwriting Recognition'
  135. pos_hint: {"center_x":0.5, "y":0.5}
  136. size_hint: 0.44,0.2
  137. Button:
  138. text: 'Change Password'
  139. pos_hint: {"center_x":0.38, "y":0.27}
  140. size_hint: 0.2,0.2
  141. on_press: root.ChangePassword()
  142. Button:
  143. text: 'Delete Account'
  144. pos_hint: {"center_x":0.38, "y":0.05}
  145. size_hint: 0.2,0.2
  146. on_press: root.DeleteAccount()
  147. Button:
  148. text: 'Log Out'
  149. pos_hint: {"center_x":0.62, "y":0.05}
  150. size_hint: 0.2,0.2
  151. on_press: root.MainScreen()
  152.  
  153. <Login_Failed>:
  154. BoxLayout:
  155. orientation: "vertical"
  156. Label:
  157. text: "Login Failed"
  158. Button:
  159. text: "Try again"
  160. on_press: root.MainScreen()
  161.  
  162. import sqlite3
  163. conn = sqlite3.connect('HandwritingRecognition.db')
  164. c = conn.cursor()
  165.  
  166. def Create():
  167. c.execute('CREATE TABLE IF NOT EXISTS Users(FirstName TEXT, Surname TEXT, Username TEXT, Passwrd TEXT)')
  168.  
  169. def Data_Entry(self):
  170. FirstName = self.ids.FirstName.text
  171. Surname = self.ids.Surname.text
  172. Username = FirstName+Surname
  173. Passwrd = self.ids.Passwrd.text
  174. c.execute("INSERT INTO Users (FirstName,Surname,Username,Passwrd) VALUES(?,?,?,?)",(FirstName,Surname,Username,Passwrd))
  175. conn.commit()
  176.  
  177. def Find_User(self):
  178. finduser = ('SELECT * FROM Users WHERE Username = ? AND Passwrd = ?')
  179. c.execute(finduser,[(self.ids.Username.text),(self.ids.Passwrd.text)])
  180. data = c.fetchall()
  181. if data:
  182. return True
  183. else:
  184. return False
  185.  
  186. def Delete_User(USER):
  187. c.execute("DELETE FROM Users WHERE Username = ?",(USER,))
Add Comment
Please, Sign In to add comment