1
0
Fork 0
forked from bton/matekasse

fixed number errors

This commit is contained in:
bton 2024-02-23 23:57:31 +01:00
parent 389e6ffcee
commit a8fec178e6

View file

@ -141,14 +141,15 @@ def create_app(test_config=None):
c = db.cursor()
try:
user_id = request.form["id"]
change = float(request.form["change"])
change = int(float(request.form["change"]) * 100)
print(change)
except:
return render_template("error.html", error_code="095")
c.execute(f"SELECT * FROM users WHERE id=?", [user_id])
users = c.fetchall()
if users != []:
balance_old = users[0][2]
c.execute(f"UPDATE users SET balance = balance + {change * 100} WHERE id={user_id}")
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
db.commit()
c.execute(f"SELECT * FROM users WHERE id={user_id}")
user = c.fetchone()