In line 17 and 19 what can i do for when i run first time it creat the file and it can read it but when i run it again dont over write it? Right now if i run it first time it says the file dosn`t exit because it read only, but if i change to write the first time it is runing ok but the secound time it cant read it.
I hope i explaind it clear
import time
import os
import webbrowser
import smtplib, ssl
port = 465
context = ssl.create_default_context()
arroba = '@'
point = '.'
print("Register:")
while True:
userid = input("Give you User name: ")
password = input("Give your password: ")
email = input("Your email: ")
emailfile = open('emailfile.txt', 'r') #email of "client"
emailcontent = emailfile.read()
userfile = open('userfile.txt', 'r')
uicontent = userfile.read()
if userid in uicontent:
print("Userid already in use!")
elif len(password) < 5:
print('Too short password, minimum 5 character')
elif arroba not in email:
print('Not valid email!')
elif point not in email:
print('Not valid email')
elif email in emailcontent:
print('Email already in use!!')
else:
with open ('userfile.txt', "a+") as f:
f.write (''.join (userid) + '\n');
with open ('passfile.txt', "a+") as f:
f.write (''.join (password) + '\n')
with open ('emailfile.txt', "a+") as f:
f.write ("".join(email) + '\n')
print("You registered successfully!!")
ui.insert(0, userid)
pw.insert(0, password)
sender_email = "email_of the sender" #company email
password = 'sender_email_password' #company email password
receiver_email = email # Enter client address
message = "You registered successfully" # sent massage
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)
break
time.sleep(2)
os.system("cls")
while True:
uicheck = open ('userfile.txt', 'r')
uicheck2 = uicheck.read()
pwcheck = open('passfile.txt', 'r')
pwcheck2 = pwcheck.read()
print("Log In:")
if input("User ID: ") in uicheck2:
if input("Password: ") in pwcheck2:
print("Succesfull LogIn!")
webbrowser.open("http://www.youtube.com", new=2)
break
else:
print("Wrong User name or password!! Try again!!")
else:
print("Wrong User name or password!! Try again!!")
You have to delete line 39 and 40 bacause i left it inside...
ui.insert(0, userid)
pw.insert(0, password)