Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| import os | |
| CUSTOMERS_FILE = "database/customers.xlsx" | |
| # Ensure database exists | |
| if not os.path.exists("database"): | |
| os.makedirs("database") | |
| if not os.path.exists(CUSTOMERS_FILE): | |
| pd.DataFrame(columns=["Name", "Phone", "Email", "Password"]).to_excel(CUSTOMERS_FILE, index=False) | |
| def check_credentials(email, password): | |
| df = pd.read_excel(CUSTOMERS_FILE) | |
| user = df[(df["Email"] == email) & (df["Password"] == password)] | |
| return not user.empty | |
| def save_user(name, phone, email, password): | |
| df = pd.read_excel(CUSTOMERS_FILE) | |
| if email in df["Email"].values: | |
| return False | |
| new_user = {"Name": name, "Phone": phone, "Email": email, "Password": password} | |
| df = pd.concat([df, pd.DataFrame([new_user])], ignore_index=True) | |
| df.to_excel(CUSTOMERS_FILE, index=False) | |
| return True | |