title: python sockets, trying to make a log in interaction betwen server and client
body: <p>Hello so i have my server with a database (dictironay) and another passworddatabase</p>
  
  <pre><code>import socket
  import sys
  from _thread import *
  host = ""
  port = 8000
  serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print("Socket Created")
  try:
      serversocket.bind((host, port))
  except socket.error as e:
      print(str(e))
      sys.exit()
  
  
  
  database = {"name1" :{"hair" : "red", "size" : 1.50}}
  
  password_database = {"name1": "1234",
                       "name2": "4321"}
  
  
  
  def client_thread(conn): #threader client
      welcome = "Welcome to the server. Type something and hit enter \n"
      conn.send(welcome.encode("UTF-8"))
      login(conn)
      while True:                # NOT IMPORTANT KEEP READING
          data = conn.recv(24)
          reply = data.decode("UTF-8")
          if reply == "1":
              menu1 = "Menu 1: Buy \n"
              conn.send(menu1.encode("UTF-8"))
          else:
              wrong = "wrong option \n"
              conn.send(wrong.encode("UTF-8"))
  
  
  
  def login(conn):  #MY LOGIC PROBLEM IS HERE
      log = "Log in MENU: \n"
      logi = log.encode("UTF-8")
      conn.send(logi)
      us = "Username: \n"
      use = us.encode("UTF-8")
      conn.send(use)
      userr = conn.recv(24)
      user = userr.decode("UTF-8")
      pa = "Password: \n"
      pasw = pa.encode("UTF-8")
      conn.send(pasw)
      passr = conn.recv(24)
      passw = passr.decode("UTF-8")
      tries = 0
      while tries &lt; 3:
          if user in passwordDictionary and passwordDictionary[user] == passw:
              print("Logged in")
              menu()
          else:
              print("Wrong Username Or Password \n")
              tries += 1
      print("You failed the login too many times, blocking you out")
      conn.close()
  
  
  
  while 1: # NOT IMPORTANT
      conn, addr = serversocket.accept()
      print("Connected with " + addr[0] + ":" + str(addr[1]))
      start_new_thread(client_thread, (conn, ))
  serversocket.close()
  </code></pre>
  
  <p>Whats working:
  The server is working fine, i'm having troubles doing the login on the client side.</p>
  
  <p>client.py ==> client DOESNT go into the <code>if data == Log in menu</code>
  is there a better way to do this?</p>
  
  <pre><code>#! /usr/bin/python3
  import socket
  
  clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  clientsocket.connect(('localhost', 8000))
  print("Connected")
  
  datae = clientsocket.recv(24)
  data = datae.decode("UTF-8")
  clientsocket.send(datae)
  while data != "!q":
      if data == "Log in MENU: \n":
          usere = input()
          user = usere.encode("UTF-8")
          clientsocket.send(user)
  </code></pre>
  
  <p>What would be the best way to create an log in interaction with the server?
  the server has the usernames and passwords, i need to log in and then i need to edit the database depending on what user was chossen, but i'm having a hard time doing the algorithm</p>