Advertisement
j7sx

reg (users, password) рабочая v. 2

Oct 21st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sqlite3 as db
  5.  
  6. #регистрация
  7. print 'input reg for reg or enter your name'
  8. _id = raw_input()
  9. if _id == 'reg':
  10.   name = raw_input("Choose your name: ")
  11.   conn = db.connect('users.db')
  12.   c = conn.cursor()
  13.   player = c.execute("SELECT COUNT(login) FROM users WHERE users.login=?", (name,))
  14.   playercount = c.fetchone()
  15.   while playercount[0] !=0:
  16.     c.execute("SELECT COUNT(login) FROM users WHERE users.login=?", (name,))
  17.     playercount = c.fetchone()
  18.     print playercount[0]
  19.     if playercount[0] !=0:
  20.       name = raw_input('User exists. Enter your name: ')
  21.   pwd = raw_input('Придумай себе пароль: ')
  22.   pwd1 = raw_input('Пароль еще раз: ')
  23.   while pwd != pwd1:
  24.     print 'Пароли не совпадают! Повтори ввод.'
  25.     pwd = raw_input('Придумай себе пароль: ')
  26.     pwd1 = raw_input('Пароль еще раз: ')
  27.   else:  
  28.     c.execute("INSERT INTO users(login, password) VALUES (?, ?)", (name, pwd, ))
  29. print 'OK'
  30. conn.commit()
  31. c.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement